aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams2011-05-10 02:28:45 -0700
committerDan Williams2011-07-03 04:04:47 -0700
commitd35bc1bd18ab9e986cfb67c5a281a70cfd717f05 (patch)
tree2f02bc1a855f1ccc2f6201f5300d1d823d80c085
parentf1f52e75939b56c40b3d153ae99faf2720250242 (diff)
isci: uplevel phy infrastructure
Merge core/scic_sds_phy.[ch] into phy.[ch] Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/Makefile1
-rw-r--r--drivers/scsi/isci/core/scic_phy.h302
-rw-r--r--drivers/scsi/isci/core/scic_port.h2
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.c2277
-rw-r--r--drivers/scsi/isci/core/scic_sds_phy.h439
-rw-r--r--drivers/scsi/isci/core/scic_sds_port.c2
-rw-r--r--drivers/scsi/isci/core/scic_sds_port_configuration_agent.h1
-rw-r--r--drivers/scsi/isci/phy.c2213
-rw-r--r--drivers/scsi/isci/phy.h574
-rw-r--r--drivers/scsi/isci/port.c2
-rw-r--r--drivers/scsi/isci/remote_device.c2
11 files changed, 2784 insertions, 3031 deletions
diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile
index a7d1eb33eca2..2830a97a822a 100644
--- a/drivers/scsi/isci/Makefile
+++ b/drivers/scsi/isci/Makefile
@@ -12,4 +12,3 @@ isci-objs := init.o phy.o request.o sata.o \
smp_request.o \
core/scic_sds_port.o \
core/scic_sds_port_configuration_agent.o \
- core/scic_sds_phy.o \
diff --git a/drivers/scsi/isci/core/scic_phy.h b/drivers/scsi/isci/core/scic_phy.h
deleted file mode 100644
index f046b4af4b8d..000000000000
--- a/drivers/scsi/isci/core/scic_phy.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SCIC_PHY_H_
-#define _SCIC_PHY_H_
-
-/**
- * This file contains all of the interface methods that can be called by an
- * SCIC user on a phy (SAS or SATA) object.
- *
- *
- */
-
-
-#include <scsi/sas.h>
-#include <scsi/libsas.h>
-
-struct scic_sds_phy;
-struct scic_sds_port;
-
-
-enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy);
-
-struct scic_phy_cap {
- union {
- struct {
- /*
- * The SAS specification indicates the start bit shall
- * always be set to
- * 1. This implementation will have the start bit set
- * to 0 if the PHY CAPABILITIES were either not
- * received or speed negotiation failed.
- */
- u8 start:1;
- u8 tx_ssc_type:1;
- u8 res1:2;
- u8 req_logical_linkrate:4;
-
- u32 gen1_no_ssc:1;
- u32 gen1_ssc:1;
- u32 gen2_no_ssc:1;
- u32 gen2_ssc:1;
- u32 gen3_no_ssc:1;
- u32 gen3_ssc:1;
- u32 res2:17;
- u32 parity:1;
- };
- u32 all;
- };
-} __packed;
-
-/* this data structure reflects the link layer transmit identification reg */
-struct scic_phy_proto {
- union {
- struct {
- u16 _r_a:1;
- u16 smp_iport:1;
- u16 stp_iport:1;
- u16 ssp_iport:1;
- u16 _r_b:4;
- u16 _r_c:1;
- u16 smp_tport:1;
- u16 stp_tport:1;
- u16 ssp_tport:1;
- u16 _r_d:4;
- };
- u16 all;
- };
-} __packed;
-
-
-/**
- * struct scic_phy_properties - This structure defines the properties common to
- * all phys that can be retrieved.
- *
- *
- */
-struct scic_phy_properties {
- /**
- * This field specifies the port that currently contains the
- * supplied phy. This field may be set to NULL
- * if the phy is not currently contained in a port.
- */
- struct scic_sds_port *owning_port;
-
- /**
- * This field specifies the link rate at which the phy is
- * currently operating.
- */
- enum sas_linkrate negotiated_link_rate;
-
- /**
- * This field specifies the index of the phy in relation to other
- * phys within the controller. This index is zero relative.
- */
- u8 index;
-};
-
-/**
- * struct scic_sas_phy_properties - This structure defines the properties,
- * specific to a SAS phy, that can be retrieved.
- *
- *
- */
-struct scic_sas_phy_properties {
- /**
- * This field delineates the Identify Address Frame received
- * from the remote end point.
- */
- struct sas_identify_frame rcvd_iaf;
-
- /**
- * This field delineates the Phy capabilities structure received
- * from the remote end point.
- */
- struct scic_phy_cap rcvd_cap;
-
-};
-
-/**
- * struct scic_sata_phy_properties - This structure defines the properties,
- * specific to a SATA phy, that can be retrieved.
- *
- *
- */
-struct scic_sata_phy_properties {
- /**
- * This field delineates the signature FIS received from the
- * attached target.
- */
- struct dev_to_host_fis signature_fis;
-
- /**
- * This field specifies to the user if a port selector is connected
- * on the specified phy.
- */
- bool is_port_selector_present;
-
-};
-
-/**
- * enum scic_phy_counter_id - This enumeration depicts the various pieces of
- * optional information that can be retrieved for a specific phy.
- *
- *
- */
-enum scic_phy_counter_id {
- /**
- * This PHY information field tracks the number of frames received.
- */
- SCIC_PHY_COUNTER_RECEIVED_FRAME,
-
- /**
- * This PHY information field tracks the number of frames transmitted.
- */
- SCIC_PHY_COUNTER_TRANSMITTED_FRAME,
-
- /**
- * This PHY information field tracks the number of DWORDs received.
- */
- SCIC_PHY_COUNTER_RECEIVED_FRAME_WORD,
-
- /**
- * This PHY information field tracks the number of DWORDs transmitted.
- */
- SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD,
-
- /**
- * This PHY information field tracks the number of times DWORD
- * synchronization was lost.
- */
- SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR,
-
- /**
- * This PHY information field tracks the number of received DWORDs with
- * running disparity errors.
- */
- SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR,
-
- /**
- * This PHY information field tracks the number of received frames with a
- * CRC error (not including short or truncated frames).
- */
- SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR,
-
- /**
- * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT)
- * primitives received.
- */
- SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT,
-
- /**
- * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT)
- * primitives transmitted.
- */
- SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT,
-
- /**
- * This PHY information field tracks the number of times the inactivity
- * timer for connections on the phy has been utilized.
- */
- SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED,
-
- /**
- * This PHY information field tracks the number of DONE (CREDIT TIMEOUT)
- * primitives received.
- */
- SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT,
-
- /**
- * This PHY information field tracks the number of DONE (CREDIT TIMEOUT)
- * primitives transmitted.
- */
- SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT,
-
- /**
- * This PHY information field tracks the number of CREDIT BLOCKED
- * primitives received.
- * @note Depending on remote device implementation, credit blocks
- * may occur regularly.
- */
- SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED,
-
- /**
- * This PHY information field contains the number of short frames
- * received. A short frame is simply a frame smaller then what is
- * allowed by either the SAS or SATA specification.
- */
- SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME,
-
- /**
- * This PHY information field contains the number of frames received after
- * credit has been exhausted.
- */
- SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT,
-
- /**
- * This PHY information field contains the number of frames received after
- * a DONE has been received.
- */
- SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE,
-
- /**
- * This PHY information field contains the number of times the phy
- * failed to achieve DWORD synchronization during speed negotiation.
- */
- SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR
-};
-
-#endif /* _SCIC_PHY_H_ */
diff --git a/drivers/scsi/isci/core/scic_port.h b/drivers/scsi/isci/core/scic_port.h
index 51e7eede5c88..431dbd2093f3 100644
--- a/drivers/scsi/isci/core/scic_port.h
+++ b/drivers/scsi/isci/core/scic_port.h
@@ -58,7 +58,7 @@
#include "isci.h"
#include "sas.h"
-#include "scic_phy.h"
+#include "phy.h"
struct scic_sds_port;
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c
deleted file mode 100644
index 150509b0c69e..000000000000
--- a/drivers/scsi/isci/core/scic_sds_phy.c
+++ /dev/null
@@ -1,2277 +0,0 @@
-/*
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <scsi/sas.h>
-#include "sas.h"
-#include "host.h"
-#include "state_machine.h"
-#include "scic_phy.h"
-#include "scic_sds_phy.h"
-#include "scic_sds_port.h"
-#include "remote_node_context.h"
-#include "scu_event_codes.h"
-#include "timers.h"
-
-#define SCIC_SDS_PHY_MIN_TIMER_COUNT (SCI_MAX_PHYS)
-#define SCIC_SDS_PHY_MAX_TIMER_COUNT (SCI_MAX_PHYS)
-
-/* Maximum arbitration wait time in micro-seconds */
-#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
-
-enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy)
-{
- return sci_phy->max_negotiated_speed;
-}
-
-/*
- * *****************************************************************************
- * * SCIC SDS PHY Internal Methods
- * ***************************************************************************** */
-
-/**
- * This method will initialize the phy transport layer registers
- * @sci_phy:
- * @transport_layer_registers
- *
- * enum sci_status
- */
-static enum sci_status scic_sds_phy_transport_layer_initialization(
- struct scic_sds_phy *sci_phy,
- struct scu_transport_layer_registers __iomem *transport_layer_registers)
-{
- u32 tl_control;
-
- sci_phy->transport_layer_registers = transport_layer_registers;
-
- writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX,
- &sci_phy->transport_layer_registers->stp_rni);
-
- /*
- * Hardware team recommends that we enable the STP prefetch for all
- * transports
- */
- tl_control = readl(&sci_phy->transport_layer_registers->control);
- tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH);
- writel(tl_control, &sci_phy->transport_layer_registers->control);
-
- return SCI_SUCCESS;
-}
-
-/**
- * This method will initialize the phy link layer registers
- * @sci_phy:
- * @link_layer_registers:
- *
- * enum sci_status
- */
-static enum sci_status
-scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
- struct scu_link_layer_registers __iomem *link_layer_registers)
-{
- struct scic_sds_controller *scic =
- sci_phy->owning_port->owning_controller;
- int phy_idx = sci_phy->phy_index;
- struct sci_phy_user_params *phy_user =
- &scic->user_parameters.sds1.phys[phy_idx];
- struct sci_phy_oem_params *phy_oem =
- &scic->oem_parameters.sds1.phys[phy_idx];
- u32 phy_configuration;
- struct scic_phy_cap phy_cap;
- u32 parity_check = 0;
- u32 parity_count = 0;
- u32 llctl, link_rate;
- u32 clksm_value = 0;
-
- sci_phy->link_layer_registers = link_layer_registers;
-
- /* Set our IDENTIFY frame data */
- #define SCI_END_DEVICE 0x01
-
- writel(SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) |
- SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) |
- SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) |
- SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) |
- SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE),
- &sci_phy->link_layer_registers->transmit_identification);
-
- /* Write the device SAS Address */
- writel(0xFEDCBA98,
- &sci_phy->link_layer_registers->sas_device_name_high);
- writel(phy_idx, &sci_phy->link_layer_registers->sas_device_name_low);
-
- /* Write the source SAS Address */
- writel(phy_oem->sas_address.high,
- &sci_phy->link_layer_registers->source_sas_address_high);
- writel(phy_oem->sas_address.low,
- &sci_phy->link_layer_registers->source_sas_address_low);
-
- /* Clear and Set the PHY Identifier */
- writel(0, &sci_phy->link_layer_registers->identify_frame_phy_id);
- writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx),
- &sci_phy->link_layer_registers->identify_frame_phy_id);
-
- /* Change the initial state of the phy configuration register */
- phy_configuration =
- readl(&sci_phy->link_layer_registers->phy_configuration);
-
- /* Hold OOB state machine in reset */
- phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
- writel(phy_configuration,
- &sci_phy->link_layer_registers->phy_configuration);
-
- /* Configure the SNW capabilities */
- phy_cap.all = 0;
- phy_cap.start = 1;
- phy_cap.gen3_no_ssc = 1;
- phy_cap.gen2_no_ssc = 1;
- phy_cap.gen1_no_ssc = 1;
- if (scic->oem_parameters.sds1.controller.do_enable_ssc == true) {
- phy_cap.gen3_ssc = 1;
- phy_cap.gen2_ssc = 1;
- phy_cap.gen1_ssc = 1;
- }
-
- /*
- * The SAS specification indicates that the phy_capabilities that
- * are transmitted shall have an even parity. Calculate the parity. */
- parity_check = phy_cap.all;
- while (parity_check != 0) {
- if (parity_check & 0x1)
- parity_count++;
- parity_check >>= 1;
- }
-
- /*
- * If parity indicates there are an odd number of bits set, then
- * set the parity bit to 1 in the phy capabilities. */
- if ((parity_count % 2) != 0)
- phy_cap.parity = 1;
-
- writel(phy_cap.all, &sci_phy->link_layer_registers->phy_capabilities);
-
- /* Set the enable spinup period but disable the ability to send
- * notify enable spinup
- */
- writel(SCU_ENSPINUP_GEN_VAL(COUNT,
- phy_user->notify_enable_spin_up_insertion_frequency),
- &sci_phy->link_layer_registers->notify_enable_spinup_control);
-
- /* Write the ALIGN Insertion Ferequency for connected phy and
- * inpendent of connected state
- */
- clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED,
- phy_user->in_connection_align_insertion_frequency);
-
- clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL,
- phy_user->align_insertion_frequency);
-
- writel(clksm_value, &sci_phy->link_layer_registers->clock_skew_management);
-
- /* @todo Provide a way to write this register correctly */
- writel(0x02108421,
- &sci_phy->link_layer_registers->afe_lookup_table_control);
-
- llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT,
- (u8)scic->user_parameters.sds1.no_outbound_task_timeout);
-
- switch(phy_user->max_speed_generation) {
- case SCIC_SDS_PARM_GEN3_SPEED:
- link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3;
- break;
- case SCIC_SDS_PARM_GEN2_SPEED:
- link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2;
- break;
- default:
- link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1;
- break;
- }
- llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate);
- writel(llctl, &sci_phy->link_layer_registers->link_layer_control);
-
- if (is_a0() || is_a2()) {
- /* Program the max ARB time for the PHY to 700us so we inter-operate with
- * the PMC expander which shuts down PHYs if the expander PHY generates too
- * many breaks. This time value will guarantee that the initiator PHY will
- * generate the break.
- */
- writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME,
- &sci_phy->link_layer_registers->maximum_arbitration_wait_timer_timeout);
- }
-
- /*
- * Set the link layer hang detection to 500ms (0x1F4) from its default
- * value of 128ms. Max value is 511 ms.
- */
- writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout);
-
- /* We can exit the initial state to the stopped state */
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STOPPED);
-
- return SCI_SUCCESS;
-}
-
-/**
- * This function will handle the sata SIGNATURE FIS timeout condition. It will
- * restart the starting substate machine since we dont know what has actually
- * happening.
- */
-static void scic_sds_phy_sata_timeout(void *phy)
-{
- struct scic_sds_phy *sci_phy = phy;
-
- dev_dbg(sciphy_to_dev(sci_phy),
- "%s: SCIC SDS Phy 0x%p did not receive signature fis before "
- "timeout.\n",
- __func__,
- sci_phy);
-
- sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
-
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STARTING);
-}
-
-/**
- * This method returns the port currently containing this phy. If the phy is
- * currently contained by the dummy port, then the phy is considered to not
- * be part of a port.
- * @sci_phy: This parameter specifies the phy for which to retrieve the
- * containing port.
- *
- * This method returns a handle to a port that contains the supplied phy.
- * NULL This value is returned if the phy is not part of a real
- * port (i.e. it's contained in the dummy port). !NULL All other
- * values indicate a handle/pointer to the port containing the phy.
- */
-struct scic_sds_port *scic_sds_phy_get_port(
- struct scic_sds_phy *sci_phy)
-{
- if (scic_sds_port_get_index(sci_phy->owning_port) == SCIC_SDS_DUMMY_PORT)
- return NULL;
-
- return sci_phy->owning_port;
-}
-
-/**
- * This method will assign a port to the phy object.
- * @out]: sci_phy This parameter specifies the phy for which to assign a port
- * object.
- *
- *
- */
-void scic_sds_phy_set_port(
- struct scic_sds_phy *sci_phy,
- struct scic_sds_port *sci_port)
-{
- sci_phy->owning_port = sci_port;
-
- if (sci_phy->bcn_received_while_port_unassigned) {
- sci_phy->bcn_received_while_port_unassigned = false;
- scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy);
- }
-}
-
-/**
- * This method will initialize the constructed phy
- * @sci_phy:
- * @link_layer_registers:
- *
- * enum sci_status
- */
-enum sci_status scic_sds_phy_initialize(
- struct scic_sds_phy *sci_phy,
- struct scu_transport_layer_registers __iomem *transport_layer_registers,
- struct scu_link_layer_registers __iomem *link_layer_registers)
-{
- struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
- struct isci_host *ihost = scic_to_ihost(scic);
-
- /* Create the SIGNATURE FIS Timeout timer for this phy */
- sci_phy->sata_timeout_timer =
- isci_timer_create(
- ihost,
- sci_phy,
- scic_sds_phy_sata_timeout);
-
- /* Perfrom the initialization of the TL hardware */
- scic_sds_phy_transport_layer_initialization(
- sci_phy,
- transport_layer_registers);
-
- /* Perofrm the initialization of the PE hardware */
- scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers);
-
- /*
- * There is nothing that needs to be done in this state just
- * transition to the stopped state. */
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STOPPED);
-
- return SCI_SUCCESS;
-}
-
-/**
- * This method assigns the direct attached device ID for this phy.
- *
- * @sci_phy The phy for which the direct attached device id is to
- * be assigned.
- * @device_id The direct attached device ID to assign to the phy.
- * This will either be the RNi for the device or an invalid RNi if there
- * is no current device assigned to the phy.
- */
-void scic_sds_phy_setup_transport(
- struct scic_sds_phy *sci_phy,
- u32 device_id)
-{
- u32 tl_control;
-
- writel(device_id, &sci_phy->transport_layer_registers->stp_rni);
-
- /*
- * The read should guarantee that the first write gets posted
- * before the next write
- */
- tl_control = readl(&sci_phy->transport_layer_registers->control);
- tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE);
- writel(tl_control, &sci_phy->transport_layer_registers->control);
-}
-
-/**
- *
- * @sci_phy: The phy object to be suspended.
- *
- * This function will perform the register reads/writes to suspend the SCU
- * hardware protocol engine. none
- */
-static void scic_sds_phy_suspend(
- struct scic_sds_phy *sci_phy)
-{
- u32 scu_sas_pcfg_value;
-
- scu_sas_pcfg_value =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
- writel(scu_sas_pcfg_value,
- &sci_phy->link_layer_registers->phy_configuration);
-
- scic_sds_phy_setup_transport(
- sci_phy,
- SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
-}
-
-void scic_sds_phy_resume(struct scic_sds_phy *sci_phy)
-{
- u32 scu_sas_pcfg_value;
-
- scu_sas_pcfg_value =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
- writel(scu_sas_pcfg_value,
- &sci_phy->link_layer_registers->phy_configuration);
-}
-
-void scic_sds_phy_get_sas_address(struct scic_sds_phy *sci_phy,
- struct sci_sas_address *sas_address)
-{
- sas_address->high = readl(&sci_phy->link_layer_registers->source_sas_address_high);
- sas_address->low = readl(&sci_phy->link_layer_registers->source_sas_address_low);
-}
-
-void scic_sds_phy_get_attached_sas_address(struct scic_sds_phy *sci_phy,
- struct sci_sas_address *sas_address)
-{
- struct sas_identify_frame *iaf;
- struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
-
- iaf = &iphy->frame_rcvd.iaf;
- memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE);
-}
-
-void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy,
- struct scic_phy_proto *protocols)
-{
- protocols->all =
- (u16)(readl(&sci_phy->
- link_layer_registers->transmit_identification) &
- 0x0000FFFF);
-}
-
-/**
- * This method will attempt to start the phy object. This request is only valid
- * when the phy is in the stopped state
- * @sci_phy:
- *
- * enum sci_status
- */
-enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy)
-{
- return sci_phy->state_handlers->start_handler(sci_phy);
-}
-
-/**
- * This method will attempt to stop the phy object.
- * @sci_phy:
- *
- * enum sci_status SCI_SUCCESS if the phy is going to stop SCI_INVALID_STATE
- * if the phy is not in a valid state to stop
- */
-enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
-{
- return sci_phy->state_handlers->stop_handler(sci_phy);
-}
-
-/**
- * This method will attempt to reset the phy. This request is only valid when
- * the phy is in an ready state
- * @sci_phy:
- *
- * enum sci_status
- */
-enum sci_status scic_sds_phy_reset(
- struct scic_sds_phy *sci_phy)
-{
- return sci_phy->state_handlers->reset_handler(sci_phy);
-}
-
-/**
- * This method will process the event code received.
- * @sci_phy:
- * @event_code:
- *
- * enum sci_status
- */
-enum sci_status scic_sds_phy_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- return sci_phy->state_handlers->event_handler(sci_phy, event_code);
-}
-
-/**
- * This method will process the frame index received.
- * @sci_phy:
- * @frame_index:
- *
- * enum sci_status
- */
-enum sci_status scic_sds_phy_frame_handler(
- struct scic_sds_phy *sci_phy,
- u32 frame_index)
-{
- return sci_phy->state_handlers->frame_handler(sci_phy, frame_index);
-}
-
-/**
- * This method will give the phy permission to consume power
- * @sci_phy:
- *
- * enum sci_status
- */
-enum sci_status scic_sds_phy_consume_power_handler(
- struct scic_sds_phy *sci_phy)
-{
- return sci_phy->state_handlers->consume_power_handler(sci_phy);
-}
-
-/*
- * *****************************************************************************
- * * SCIC SDS PHY HELPER FUNCTIONS
- * ***************************************************************************** */
-
-
-/**
- *
- * @sci_phy: The phy object that received SAS PHY DETECTED.
- *
- * This method continues the link training for the phy as if it were a SAS PHY
- * instead of a SATA PHY. This is done because the completion queue had a SAS
- * PHY DETECTED event when the state machine was expecting a SATA PHY event.
- * none
- */
-static void scic_sds_phy_start_sas_link_training(
- struct scic_sds_phy *sci_phy)
-{
- u32 phy_control;
-
- phy_control =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD);
- writel(phy_control,
- &sci_phy->link_layer_registers->phy_configuration);
-
- sci_base_state_machine_change_state(
- &sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
- );
-
- sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS;
-}
-
-/**
- *
- * @sci_phy: The phy object that received a SATA SPINUP HOLD event
- *
- * This method continues the link training for the phy as if it were a SATA PHY
- * instead of a SAS PHY. This is done because the completion queue had a SATA
- * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none
- */
-static void scic_sds_phy_start_sata_link_training(
- struct scic_sds_phy *sci_phy)
-{
- sci_base_state_machine_change_state(
- &sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
- );
-
- sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
-}
-
-/**
- * scic_sds_phy_complete_link_training - perform processing common to
- * all protocols upon completion of link training.
- * @sci_phy: This parameter specifies the phy object for which link training
- * has completed.
- * @max_link_rate: This parameter specifies the maximum link rate to be
- * associated with this phy.
- * @next_state: This parameter specifies the next state for the phy's starting
- * sub-state machine.
- *
- */
-static void scic_sds_phy_complete_link_training(
- struct scic_sds_phy *sci_phy,
- enum sas_linkrate max_link_rate,
- u32 next_state)
-{
- sci_phy->max_negotiated_speed = max_link_rate;
-
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- next_state);
-}
-
-static void scic_sds_phy_restart_starting_state(
- struct scic_sds_phy *sci_phy)
-{
- /* Stop the current substate machine */
- sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
-
- /* Re-enter the base state machine starting state */
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STARTING);
-}
-
-/* ****************************************************************************
- * SCIC SDS PHY general handlers
- ************************************************************************** */
-static enum sci_status scic_sds_phy_starting_substate_general_stop_handler(
- struct scic_sds_phy *phy)
-{
- sci_base_state_machine_stop(&phy->starting_substate_machine);
-
- sci_base_state_machine_change_state(&phy->state_machine,
- SCI_BASE_PHY_STATE_STOPPED);
-
- return SCI_SUCCESS;
-}
-
-/*
- * *****************************************************************************
- * * SCIC SDS PHY EVENT_HANDLERS
- * ***************************************************************************** */
-
-/**
- *
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. -
- * decode the event - sas phy detected causes a state transition to the wait
- * for speed event notification. - any other events log a warning message and
- * set a failure status enum sci_status SCI_SUCCESS on any valid event notification
- * SCI_FAILURE on any unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_ossp_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_SAS_PHY_DETECTED:
- scic_sds_phy_start_sas_link_training(sci_phy);
- sci_phy->is_in_link_training = true;
- break;
-
- case SCU_EVENT_SATA_SPINUP_HOLD:
- scic_sds_phy_start_sata_link_training(sci_phy);
- sci_phy->is_in_link_training = true;
- break;
-
- default:
- dev_dbg(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- *
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. -
- * decode the event - sas phy detected returns us back to this state. - speed
- * event detected causes a state transition to the wait for iaf. - identify
- * timeout is an un-expected event and the state machine is restarted. - link
- * failure events restart the starting state machine - any other events log a
- * warning message and set a failure status enum sci_status SCI_SUCCESS on any valid
- * event notification SCI_FAILURE on any unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_SAS_PHY_DETECTED:
- /*
- * Why is this being reported again by the controller?
- * We would re-enter this state so just stay here */
- break;
-
- case SCU_EVENT_SAS_15:
- case SCU_EVENT_SAS_15_SSC:
- scic_sds_phy_complete_link_training(
- sci_phy,
- SAS_LINK_RATE_1_5_GBPS,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF);
- break;
-
- case SCU_EVENT_SAS_30:
- case SCU_EVENT_SAS_30_SSC:
- scic_sds_phy_complete_link_training(
- sci_phy,
- SAS_LINK_RATE_3_0_GBPS,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF);
- break;
-
- case SCU_EVENT_SAS_60:
- case SCU_EVENT_SAS_60_SSC:
- scic_sds_phy_complete_link_training(
- sci_phy,
- SAS_LINK_RATE_6_0_GBPS,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF);
- break;
-
- case SCU_EVENT_SATA_SPINUP_HOLD:
- /*
- * We were doing SAS PHY link training and received a SATA PHY event
- * continue OOB/SN as if this were a SATA PHY */
- scic_sds_phy_start_sata_link_training(sci_phy);
- break;
-
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- *
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. -
- * decode the event - sas phy detected event backs up the state machine to the
- * await speed notification. - identify timeout is an un-expected event and the
- * state machine is restarted. - link failure events restart the starting state
- * machine - any other events log a warning message and set a failure status
- * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any
- * unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_SAS_PHY_DETECTED:
- /* Backup the state machine */
- scic_sds_phy_start_sas_link_training(sci_phy);
- break;
-
- case SCU_EVENT_SATA_SPINUP_HOLD:
- /*
- * We were doing SAS PHY link training and received a SATA PHY event
- * continue OOB/SN as if this were a SATA PHY */
- scic_sds_phy_start_sata_link_training(sci_phy);
- break;
-
- case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
- case SCU_EVENT_LINK_FAILURE:
- case SCU_EVENT_HARD_RESET_RECEIVED:
- /* Start the oob/sn state machine over again */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- *
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_POWER. -
- * decode the event - link failure events restart the starting state machine -
- * any other events log a warning message and set a failure status enum sci_status
- * SCI_SUCCESS on a link failure event SCI_FAILURE on any unexpected event
- * notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sas_power_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received unexpected "
- "event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- *
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. -
- * decode the event - link failure events restart the starting state machine -
- * sata spinup hold events are ignored since they are expected - any other
- * events log a warning message and set a failure status enum sci_status SCI_SUCCESS
- * on a link failure event SCI_FAILURE on any unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- case SCU_EVENT_SATA_SPINUP_HOLD:
- /* These events are received every 10ms and are expected while in this state */
- break;
-
- case SCU_EVENT_SAS_PHY_DETECTED:
- /*
- * There has been a change in the phy type before OOB/SN for the
- * SATA finished start down the SAS link traning path. */
- scic_sds_phy_start_sas_link_training(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- * scic_sds_phy_starting_substate_await_sata_phy_event_handler -
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. -
- * decode the event - link failure events restart the starting state machine -
- * sata spinup hold events are ignored since they are expected - sata phy
- * detected event change to the wait speed event - any other events log a
- * warning message and set a failure status enum sci_status SCI_SUCCESS on a link
- * failure event SCI_FAILURE on any unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler(
- struct scic_sds_phy *sci_phy, u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- case SCU_EVENT_SATA_SPINUP_HOLD:
- /* These events might be received since we dont know how many may be in
- * the completion queue while waiting for power
- */
- break;
-
- case SCU_EVENT_SATA_PHY_DETECTED:
- sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
-
- /* We have received the SATA PHY notification change state */
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
- break;
-
- case SCU_EVENT_SAS_PHY_DETECTED:
- /* There has been a change in the phy type before OOB/SN for the
- * SATA finished start down the SAS link traning path.
- */
- scic_sds_phy_start_sas_link_training(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- *
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN.
- * - decode the event - sata phy detected returns us back to this state. -
- * speed event detected causes a state transition to the wait for signature. -
- * link failure events restart the starting state machine - any other events
- * log a warning message and set a failure status enum sci_status SCI_SUCCESS on any
- * valid event notification SCI_FAILURE on any unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_handler(
- struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_SATA_PHY_DETECTED:
- /*
- * The hardware reports multiple SATA PHY detected events
- * ignore the extras */
- break;
-
- case SCU_EVENT_SATA_15:
- case SCU_EVENT_SATA_15_SSC:
- scic_sds_phy_complete_link_training(
- sci_phy,
- SAS_LINK_RATE_1_5_GBPS,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
- break;
-
- case SCU_EVENT_SATA_30:
- case SCU_EVENT_SATA_30_SSC:
- scic_sds_phy_complete_link_training(
- sci_phy,
- SAS_LINK_RATE_3_0_GBPS,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
- break;
-
- case SCU_EVENT_SATA_60:
- case SCU_EVENT_SATA_60_SSC:
- scic_sds_phy_complete_link_training(
- sci_phy,
- SAS_LINK_RATE_6_0_GBPS,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
- break;
-
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- case SCU_EVENT_SAS_PHY_DETECTED:
- /*
- * There has been a change in the phy type before OOB/SN for the
- * SATA finished start down the SAS link traning path. */
- scic_sds_phy_start_sas_link_training(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-/**
- * scic_sds_phy_starting_substate_await_sig_fis_event_handler -
- * @phy: This struct scic_sds_phy object which has received an event.
- * @event_code: This is the event code which the phy object is to decode.
- *
- * This method is called when an event notification is received for the phy
- * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. -
- * decode the event - sas phy detected event backs up the state machine to the
- * await speed notification. - identify timeout is an un-expected event and the
- * state machine is restarted. - link failure events restart the starting state
- * machine - any other events log a warning message and set a failure status
- * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any
- * unexpected event notifation
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler(
- struct scic_sds_phy *sci_phy, u32 event_code)
-{
- u32 result = SCI_SUCCESS;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_SATA_PHY_DETECTED:
- /* Backup the state machine */
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
- break;
-
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- scic_sds_phy_restart_starting_state(sci_phy);
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected event_code %x\n",
- __func__,
- event_code);
-
- result = SCI_FAILURE;
- break;
- }
-
- return result;
-}
-
-
-/*
- * *****************************************************************************
- * * SCIC SDS PHY FRAME_HANDLERS
- * ***************************************************************************** */
-
-/**
- *
- * @phy: This is struct scic_sds_phy object which is being requested to decode the
- * frame data.
- * @frame_index: This is the index of the unsolicited frame which was received
- * for this phy.
- *
- * This method decodes the unsolicited frame when the struct scic_sds_phy is in the
- * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Get the UF Header - If the UF
- * is an IAF - Copy IAF data to local phy object IAF data buffer. - Change
- * starting substate to wait power. - else - log warning message of unexpected
- * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler(
- struct scic_sds_phy *sci_phy, u32 frame_index)
-{
- enum sci_status result;
- u32 *frame_words;
- struct sas_identify_frame iaf;
- struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
-
- result = scic_sds_unsolicited_frame_control_get_header(
- &(scic_sds_phy_get_controller(sci_phy)->uf_control),
- frame_index,
- (void **)&frame_words);
-
- if (result != SCI_SUCCESS)
- return result;
-
- sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32));
- if (iaf.frame_type == 0) {
- u32 state;
-
- memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf));
- if (iaf.smp_tport) {
- /* We got the IAF for an expander PHY go to the final
- * state since there are no power requirements for
- * expander phys.
- */
- state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL;
- } else {
- /* We got the IAF we can now go to the await spinup
- * semaphore state
- */
- state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER;
- }
- sci_base_state_machine_change_state(
- &sci_phy->starting_substate_machine,
- state);
- result = SCI_SUCCESS;
- } else
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected frame id %x\n",
- __func__,
- frame_index);
-
- scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
- frame_index);
-
- return result;
-}
-
-/**
- *
- * @phy: This is struct scic_sds_phy object which is being requested to decode the
- * frame data.
- * @frame_index: This is the index of the unsolicited frame which was received
- * for this phy.
- *
- * This method decodes the unsolicited frame when the struct scic_sds_phy is in the
- * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Get the UF Header - If
- * the UF is an SIGNATURE FIS - Copy IAF data to local phy object SIGNATURE FIS
- * data buffer. - else - log warning message of unexpected unsolicted frame -
- * release frame buffer enum sci_status SCI_SUCCESS Must decode the SIGNATURE FIS
- * data
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler(
- struct scic_sds_phy *sci_phy,
- u32 frame_index)
-{
- enum sci_status result;
- struct dev_to_host_fis *frame_header;
- u32 *fis_frame_data;
- struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
-
- result = scic_sds_unsolicited_frame_control_get_header(
- &(scic_sds_phy_get_controller(sci_phy)->uf_control),
- frame_index,
- (void **)&frame_header);
-
- if (result != SCI_SUCCESS)
- return result;
-
- if ((frame_header->fis_type == FIS_REGD2H) &&
- !(frame_header->status & ATA_BUSY)) {
- scic_sds_unsolicited_frame_control_get_buffer(
- &(scic_sds_phy_get_controller(sci_phy)->uf_control),
- frame_index,
- (void **)&fis_frame_data);
-
- scic_sds_controller_copy_sata_response(&iphy->frame_rcvd.fis,
- frame_header,
- fis_frame_data);
-
- /* got IAF we can now go to the await spinup semaphore state */
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
-
- result = SCI_SUCCESS;
- } else
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: PHY starting substate machine received "
- "unexpected frame id %x\n",
- __func__,
- frame_index);
-
- /* Regardless of the result we are done with this frame with it */
- scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
- frame_index);
-
- return result;
-}
-
-/*
- * *****************************************************************************
- * * SCIC SDS PHY POWER_HANDLERS
- * ***************************************************************************** */
-
-/*
- * This method is called by the struct scic_sds_controller when the phy object is
- * granted power. - The notify enable spinups are turned on for this phy object
- * - The phy state machine is transitioned to the
- * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler(
- struct scic_sds_phy *sci_phy)
-{
- u32 enable_spinup;
-
- enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
- enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
- writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control);
-
- /* Change state to the final state this substate machine has run to completion */
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
-
- return SCI_SUCCESS;
-}
-
-/*
- * This method is called by the struct scic_sds_controller when the phy object is
- * granted power. - The phy state machine is transitioned to the
- * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS
- */
-static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler(
- struct scic_sds_phy *sci_phy)
-{
- u32 scu_sas_pcfg_value;
-
- /* Release the spinup hold state and reset the OOB state machine */
- scu_sas_pcfg_value =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- scu_sas_pcfg_value &=
- ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
- scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
- writel(scu_sas_pcfg_value,
- &sci_phy->link_layer_registers->phy_configuration);
-
- /* Now restart the OOB operation */
- scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
- scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
- writel(scu_sas_pcfg_value,
- &sci_phy->link_layer_registers->phy_configuration);
-
- /* Change state to the final state this substate machine has run to completion */
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
-
- return SCI_SUCCESS;
-}
-
-static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy,
- const char *func)
-{
- dev_dbg(sciphy_to_dev(sci_phy),
- "%s: in wrong state: %d\n", func,
- sci_base_state_machine_get_state(&sci_phy->state_machine));
- return SCI_FAILURE_INVALID_STATE;
-}
-
-static enum sci_status
-scic_sds_phy_default_start_handler(struct scic_sds_phy *sci_phy)
-{
- return default_phy_handler(sci_phy, __func__);
-}
-
-static enum sci_status
-scic_sds_phy_default_stop_handler(struct scic_sds_phy *sci_phy)
-{
- return default_phy_handler(sci_phy, __func__);
-}
-
-static enum sci_status
-scic_sds_phy_default_reset_handler(struct scic_sds_phy *sci_phy)
-{
- return default_phy_handler(sci_phy, __func__);
-}
-
-static enum sci_status
-scic_sds_phy_default_destroy_handler(struct scic_sds_phy *sci_phy)
-{
- return default_phy_handler(sci_phy, __func__);
-}
-
-static enum sci_status
-scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy,
- u32 frame_index)
-{
- struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
-
- default_phy_handler(sci_phy, __func__);
- scic_sds_controller_release_frame(scic, frame_index);
-
- return SCI_FAILURE_INVALID_STATE;
-}
-
-static enum sci_status
-scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- return default_phy_handler(sci_phy, __func__);
-}
-
-static enum sci_status
-scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy)
-{
- return default_phy_handler(sci_phy, __func__);
-}
-
-
-
-static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = {
- [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_default_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_default_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler,
- .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler,
- .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
- .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_default_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- }
-};
-
-/**
- * scic_sds_phy_set_starting_substate_handlers() -
- *
- * This macro sets the starting substate handlers by state_id
- */
-#define scic_sds_phy_set_starting_substate_handlers(phy, state_id) \
- scic_sds_phy_set_state_handlers(\
- (phy), \
- &scic_sds_phy_starting_substate_handler_table[(state_id)] \
- )
-
-/*
- * ****************************************************************************
- * * PHY STARTING SUBSTATE METHODS
- * **************************************************************************** */
-
-/**
- * scic_sds_phy_starting_initial_substate_enter -
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL. - The initial state
- * handlers are put in place for the struct scic_sds_phy object. - The state is
- * changed to the wait phy type event notification. none
- */
-static void scic_sds_phy_starting_initial_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
-
- /* This is just an temporary state go off to the starting state */
- sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_PHY_TYPE_EN. - Set the
- * struct scic_sds_phy object state handlers for this state. none
- */
-static void scic_sds_phy_starting_await_ossp_en_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - Set the
- * struct scic_sds_phy object state handlers for this state. none
- */
-static void scic_sds_phy_starting_await_sas_speed_en_substate_enter(
- void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Set the
- * struct scic_sds_phy object state handlers for this state. none
- */
-static void scic_sds_phy_starting_await_iaf_uf_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Set the
- * struct scic_sds_phy object state handlers for this state. - Add this phy object to
- * the power control queue none
- */
-static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
- );
-
- scic_sds_controller_power_control_queue_insert(
- scic_sds_phy_get_controller(sci_phy),
- sci_phy
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on exiting
- * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Remove the
- * struct scic_sds_phy object from the power control queue. none
- */
-static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_controller_power_control_queue_remove(
- scic_sds_phy_get_controller(sci_phy), sci_phy
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Set the
- * struct scic_sds_phy object state handlers for this state. - Add this phy object to
- * the power control queue none
- */
-static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
- );
-
- scic_sds_controller_power_control_queue_insert(
- scic_sds_phy_get_controller(sci_phy),
- sci_phy
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on exiting
- * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Remove the
- * struct scic_sds_phy object from the power control queue. none
- */
-static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_controller_power_control_queue_remove(
- scic_sds_phy_get_controller(sci_phy),
- sci_phy
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This function will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the
- * struct scic_sds_phy object state handlers for this state. none
- */
-static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
-
- isci_timer_start(sci_phy->sata_timeout_timer,
- SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy
- * on exiting
- * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
- * that was started on entry to await sata phy event notification none
- */
-static inline void scic_sds_phy_starting_await_sata_phy_substate_exit(
- void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- isci_timer_stop(sci_phy->sata_timeout_timer);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - Set the
- * struct scic_sds_phy object state handlers for this state. none
- */
-static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
-
- isci_timer_start(sci_phy->sata_timeout_timer,
- SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This function will perform the actions required by the
- * struct scic_sds_phy on exiting
- * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
- * that was started on entry to await sata phy event notification none
- */
-static inline void scic_sds_phy_starting_await_sata_speed_substate_exit(
- void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- isci_timer_stop(sci_phy->sata_timeout_timer);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This function will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the
- * struct scic_sds_phy object state handlers for this state.
- * - Start the SIGNATURE FIS
- * timeout timer none
- */
-static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object)
-{
- bool continue_to_ready_state;
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(
- sci_phy,
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
-
- continue_to_ready_state = scic_sds_port_link_detected(
- sci_phy->owning_port,
- sci_phy);
-
- if (continue_to_ready_state) {
- /*
- * Clear the PE suspend condition so we can actually
- * receive SIG FIS
- * The hardware will not respond to the XRDY until the PE
- * suspend condition is cleared.
- */
- scic_sds_phy_resume(sci_phy);
-
- isci_timer_start(sci_phy->sata_timeout_timer,
- SCIC_SDS_SIGNATURE_FIS_TIMEOUT);
- } else
- sci_phy->is_in_link_training = false;
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This function will perform the actions required by the
- * struct scic_sds_phy on exiting
- * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE
- * FIS timeout timer. none
- */
-static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(
- void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- isci_timer_stop(sci_phy->sata_timeout_timer);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. - Set the struct scic_sds_phy
- * object state handlers for this state. - Change base state machine to the
- * ready state. none
- */
-static void scic_sds_phy_starting_final_substate_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_starting_substate_handlers(sci_phy,
- SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
-
- /* State machine has run to completion so exit out and change
- * the base state machine to the ready state
- */
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_READY);
-}
-
-/* --------------------------------------------------------------------------- */
-
-static const struct sci_base_state scic_sds_phy_starting_substates[] = {
- [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
- .enter_state = scic_sds_phy_starting_initial_substate_enter,
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
- .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter,
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
- .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter,
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
- .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter,
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
- .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter,
- .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit,
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
- .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter,
- .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
- .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter,
- .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
- .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter,
- .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
- .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter,
- .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit
- },
- [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
- .enter_state = scic_sds_phy_starting_final_substate_enter,
- }
-};
-
-/*
- * This method takes the struct scic_sds_phy from a stopped state and
- * attempts to start it. - The phy state machine is transitioned to the
- * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS
- */
-static enum sci_status
-scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy)
-{
- struct isci_host *ihost;
- struct scic_sds_controller *scic;
-
- scic = scic_sds_phy_get_controller(sci_phy),
- ihost = scic_to_ihost(scic);
-
- /* Create the SIGNATURE FIS Timeout timer for this phy */
- sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy,
- scic_sds_phy_sata_timeout);
-
- if (sci_phy->sata_timeout_timer)
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STARTING);
-
- return SCI_SUCCESS;
-}
-
-static enum sci_status
-scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy)
-{
- return SCI_SUCCESS;
-}
-
-static enum sci_status
-scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy)
-{
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STOPPED);
-
- return SCI_SUCCESS;
-}
-
-static enum sci_status
-scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy)
-{
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_RESETTING);
-
- return SCI_SUCCESS;
-}
-
-/**
- * scic_sds_phy_ready_state_event_handler -
- * @phy: This is the struct scic_sds_phy object which has received the event.
- *
- * This method request the struct scic_sds_phy handle the received event. The only
- * event that we are interested in while in the ready state is the link failure
- * event. - decoded event is a link failure - transition the struct scic_sds_phy back
- * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will
- * report a warning message enum sci_status SCI_SUCCESS if the event received is a
- * link failure SCI_FAILURE_INVALID_STATE for any other event received.
- */
-static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- enum sci_status result = SCI_FAILURE;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_LINK_FAILURE:
- /* Link failure change state back to the starting state */
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STARTING);
- result = SCI_SUCCESS;
- break;
-
- case SCU_EVENT_BROADCAST_CHANGE:
- /* Broadcast change received. Notify the port. */
- if (scic_sds_phy_get_port(sci_phy) != NULL)
- scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy);
- else
- sci_phy->bcn_received_while_port_unassigned = true;
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%sP SCIC PHY 0x%p ready state machine received "
- "unexpected event_code %x\n",
- __func__, sci_phy, event_code);
-
- result = SCI_FAILURE_INVALID_STATE;
- break;
- }
-
- return result;
-}
-
-static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy,
- u32 event_code)
-{
- enum sci_status result = SCI_FAILURE;
-
- switch (scu_get_event_code(event_code)) {
- case SCU_EVENT_HARD_RESET_TRANSMITTED:
- /* Link failure change state back to the starting state */
- sci_base_state_machine_change_state(&sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STARTING);
- result = SCI_SUCCESS;
- break;
-
- default:
- dev_warn(sciphy_to_dev(sci_phy),
- "%s: SCIC PHY 0x%p resetting state machine received "
- "unexpected event_code %x\n",
- __func__, sci_phy, event_code);
-
- result = SCI_FAILURE_INVALID_STATE;
- break;
- }
-
- return result;
-}
-
-/* --------------------------------------------------------------------------- */
-
-static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
- [SCI_BASE_PHY_STATE_INITIAL] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_default_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_default_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCI_BASE_PHY_STATE_STOPPED] = {
- .start_handler = scic_sds_phy_stopped_state_start_handler,
- .stop_handler = scic_sds_phy_default_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_stopped_state_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_default_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCI_BASE_PHY_STATE_STARTING] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_default_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_default_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCI_BASE_PHY_STATE_READY] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_ready_state_stop_handler,
- .reset_handler = scic_sds_phy_ready_state_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_ready_state_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCI_BASE_PHY_STATE_RESETTING] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_default_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_resetting_state_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- },
- [SCI_BASE_PHY_STATE_FINAL] = {
- .start_handler = scic_sds_phy_default_start_handler,
- .stop_handler = scic_sds_phy_default_stop_handler,
- .reset_handler = scic_sds_phy_default_reset_handler,
- .destruct_handler = scic_sds_phy_default_destroy_handler,
- .frame_handler = scic_sds_phy_default_frame_handler,
- .event_handler = scic_sds_phy_default_event_handler,
- .consume_power_handler = scic_sds_phy_default_consume_power_handler
- }
-};
-
-/*
- * ****************************************************************************
- * * PHY STATE PRIVATE METHODS
- * **************************************************************************** */
-
-/**
- *
- * @sci_phy: This is the struct scic_sds_phy object to stop.
- *
- * This method will stop the struct scic_sds_phy object. This does not reset the
- * protocol engine it just suspends it and places it in a state where it will
- * not cause the end device to power up. none
- */
-static void scu_link_layer_stop_protocol_engine(
- struct scic_sds_phy *sci_phy)
-{
- u32 scu_sas_pcfg_value;
- u32 enable_spinup_value;
-
- /* Suspend the protocol engine and place it in a sata spinup hold state */
- scu_sas_pcfg_value =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- scu_sas_pcfg_value |=
- (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
- SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) |
- SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD));
- writel(scu_sas_pcfg_value,
- &sci_phy->link_layer_registers->phy_configuration);
-
- /* Disable the notify enable spinup primitives */
- enable_spinup_value = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
- enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE);
- writel(enable_spinup_value, &sci_phy->link_layer_registers->notify_enable_spinup_control);
-}
-
-/**
- *
- *
- * This method will start the OOB/SN state machine for this struct scic_sds_phy object.
- */
-static void scu_link_layer_start_oob(
- struct scic_sds_phy *sci_phy)
-{
- u32 scu_sas_pcfg_value;
-
- scu_sas_pcfg_value =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
- scu_sas_pcfg_value &=
- ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
- SCU_SAS_PCFG_GEN_BIT(HARD_RESET));
- writel(scu_sas_pcfg_value,
- &sci_phy->link_layer_registers->phy_configuration);
-}
-
-/**
- *
- *
- * This method will transmit a hard reset request on the specified phy. The SCU
- * hardware requires that we reset the OOB state machine and set the hard reset
- * bit in the phy configuration register. We then must start OOB over with the
- * hard reset bit set.
- */
-static void scu_link_layer_tx_hard_reset(
- struct scic_sds_phy *sci_phy)
-{
- u32 phy_configuration_value;
-
- /*
- * SAS Phys must wait for the HARD_RESET_TX event notification to transition
- * to the starting state. */
- phy_configuration_value =
- readl(&sci_phy->link_layer_registers->phy_configuration);
- phy_configuration_value |=
- (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) |
- SCU_SAS_PCFG_GEN_BIT(OOB_RESET));
- writel(phy_configuration_value,
- &sci_phy->link_layer_registers->phy_configuration);
-
- /* Now take the OOB state machine out of reset */
- phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
- phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
- writel(phy_configuration_value,
- &sci_phy->link_layer_registers->phy_configuration);
-}
-
-/*
- * ****************************************************************************
- * * PHY BASE STATE METHODS
- * **************************************************************************** */
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
- * handlers for the phy object base state machine initial state. none
- */
-static void scic_sds_phy_initial_state_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_INITIAL);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This function will perform the actions required by the struct scic_sds_phy on
- * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
- * handlers for the phy object base state machine initial state. - The SCU
- * hardware is requested to stop the protocol engine. none
- */
-static void scic_sds_phy_stopped_state_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
- struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
- struct isci_host *ihost = scic_to_ihost(scic);
-
- /*
- * @todo We need to get to the controller to place this PE in a
- * reset state
- */
-
- scic_sds_phy_set_base_state_handlers(sci_phy,
- SCI_BASE_PHY_STATE_STOPPED);
-
- if (sci_phy->sata_timeout_timer != NULL) {
- isci_del_timer(ihost, sci_phy->sata_timeout_timer);
-
- sci_phy->sata_timeout_timer = NULL;
- }
-
- scu_link_layer_stop_protocol_engine(sci_phy);
-
- if (sci_phy->state_machine.previous_state_id !=
- SCI_BASE_PHY_STATE_INITIAL)
- scic_sds_controller_link_down(
- scic_sds_phy_get_controller(sci_phy),
- scic_sds_phy_get_port(sci_phy),
- sci_phy);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCI_BASE_PHY_STATE_STARTING. - This function sets the state
- * handlers for the phy object base state machine starting state. - The SCU
- * hardware is requested to start OOB/SN on this protocl engine. - The phy
- * starting substate machine is started. - If the previous state was the ready
- * state then the struct scic_sds_controller is informed that the phy has gone link
- * down. none
- */
-static void scic_sds_phy_starting_state_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_STARTING);
-
- scu_link_layer_stop_protocol_engine(sci_phy);
- scu_link_layer_start_oob(sci_phy);
-
- /* We don't know what kind of phy we are going to be just yet */
- sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
- sci_phy->bcn_received_while_port_unassigned = false;
-
- /* Change over to the starting substate machine to continue */
- sci_base_state_machine_start(&sci_phy->starting_substate_machine);
-
- if (sci_phy->state_machine.previous_state_id
- == SCI_BASE_PHY_STATE_READY) {
- scic_sds_controller_link_down(
- scic_sds_phy_get_controller(sci_phy),
- scic_sds_phy_get_port(sci_phy),
- sci_phy
- );
- }
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCI_BASE_PHY_STATE_READY. - This function sets the state
- * handlers for the phy object base state machine ready state. - The SCU
- * hardware protocol engine is resumed. - The struct scic_sds_controller is informed
- * that the phy object has gone link up. none
- */
-static void scic_sds_phy_ready_state_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_READY);
-
- scic_sds_controller_link_up(
- scic_sds_phy_get_controller(sci_phy),
- scic_sds_phy_get_port(sci_phy),
- sci_phy
- );
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on exiting
- * the SCI_BASE_PHY_STATE_INITIAL. This function suspends the SCU hardware
- * protocol engine represented by this struct scic_sds_phy object. none
- */
-static void scic_sds_phy_ready_state_exit(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_suspend(sci_phy);
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCI_BASE_PHY_STATE_RESETTING. - This function sets the state
- * handlers for the phy object base state machine resetting state. none
- */
-static void scic_sds_phy_resetting_state_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_RESETTING);
-
- /*
- * The phy is being reset, therefore deactivate it from the port.
- * In the resetting state we don't notify the user regarding
- * link up and link down notifications. */
- scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false);
-
- if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
- scu_link_layer_tx_hard_reset(sci_phy);
- } else {
- /*
- * The SCU does not need to have a discrete reset state so
- * just go back to the starting state.
- */
- sci_base_state_machine_change_state(
- &sci_phy->state_machine,
- SCI_BASE_PHY_STATE_STARTING);
- }
-}
-
-/**
- *
- * @object: This is the object which is cast to a struct scic_sds_phy object.
- *
- * This method will perform the actions required by the struct scic_sds_phy on
- * entering the SCI_BASE_PHY_STATE_FINAL. - This function sets the state
- * handlers for the phy object base state machine final state. none
- */
-static void scic_sds_phy_final_state_enter(void *object)
-{
- struct scic_sds_phy *sci_phy = object;
-
- scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_FINAL);
-
- /* Nothing to do here */
-}
-
-/* --------------------------------------------------------------------------- */
-
-static const struct sci_base_state scic_sds_phy_state_table[] = {
- [SCI_BASE_PHY_STATE_INITIAL] = {
- .enter_state = scic_sds_phy_initial_state_enter,
- },
- [SCI_BASE_PHY_STATE_STOPPED] = {
- .enter_state = scic_sds_phy_stopped_state_enter,
- },
- [SCI_BASE_PHY_STATE_STARTING] = {
- .enter_state = scic_sds_phy_starting_state_enter,
- },
- [SCI_BASE_PHY_STATE_READY] = {
- .enter_state = scic_sds_phy_ready_state_enter,
- .exit_state = scic_sds_phy_ready_state_exit,
- },
- [SCI_BASE_PHY_STATE_RESETTING] = {
- .enter_state = scic_sds_phy_resetting_state_enter,
- },
- [SCI_BASE_PHY_STATE_FINAL] = {
- .enter_state = scic_sds_phy_final_state_enter,
- },
-};
-
-void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
- struct scic_sds_port *owning_port, u8 phy_index)
-{
- sci_base_state_machine_construct(&sci_phy->state_machine,
- sci_phy,
- scic_sds_phy_state_table,
- SCI_BASE_PHY_STATE_INITIAL);
-
- sci_base_state_machine_start(&sci_phy->state_machine);
-
- /* Copy the rest of the input data to our locals */
- sci_phy->owning_port = owning_port;
- sci_phy->phy_index = phy_index;
- sci_phy->bcn_received_while_port_unassigned = false;
- sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
- sci_phy->link_layer_registers = NULL;
- sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
- sci_phy->sata_timeout_timer = NULL;
-
- /* Initialize the the substate machines */
- sci_base_state_machine_construct(&sci_phy->starting_substate_machine,
- sci_phy,
- scic_sds_phy_starting_substates,
- SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
-}
diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h
deleted file mode 100644
index 0d7bab3fc93b..000000000000
--- a/drivers/scsi/isci/core/scic_sds_phy.h
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * This file is provided under a dual BSD/GPLv2 license. When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- * The full GNU General Public License is included in this distribution
- * in the file called LICENSE.GPL.
- *
- * BSD LICENSE
- *
- * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SCIC_SDS_PHY_H_
-#define _SCIC_SDS_PHY_H_
-
-#include "sas.h"
-#include "scic_phy.h"
-#include "registers.h"
-#include "state_machine.h"
-#include <scsi/libsas.h>
-
-struct scic_sds_port;
-/**
- *
- *
- * This is the timeout value for the SATA phy to wait for a SIGNATURE FIS
- * before restarting the starting state machine. Technically, the old parallel
- * ATA specification required up to 30 seconds for a device to issue its
- * signature FIS as a result of a soft reset. Now we see that devices respond
- * generally within 15 seconds, but we'll use 25 for now.
- */
-#define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000
-
-/**
- *
- *
- * This is the timeout for the SATA OOB/SN because the hardware does not
- * recognize a hot plug after OOB signal but before the SN signals. We need to
- * make sure after a hotplug timeout if we have not received the speed event
- * notification from the hardware that we restart the hardware OOB state
- * machine.
- */
-#define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250
-
-enum scic_sds_phy_states {
- /**
- * Simply the initial state for the base domain state machine.
- */
- SCI_BASE_PHY_STATE_INITIAL,
-
- /**
- * This state indicates that the phy has successfully been stopped.
- * In this state no new IO operations are permitted on this phy.
- * This state is entered from the INITIAL state.
- * This state is entered from the STARTING state.
- * This state is entered from the READY state.
- * This state is entered from the RESETTING state.
- */
- SCI_BASE_PHY_STATE_STOPPED,
-
- /**
- * This state indicates that the phy is in the process of becomming
- * ready. In this state no new IO operations are permitted on this phy.
- * This state is entered from the STOPPED state.
- * This state is entered from the READY state.
- * This state is entered from the RESETTING state.
- */
- SCI_BASE_PHY_STATE_STARTING,
-
- /**
- * This state indicates the the phy is now ready. Thus, the user
- * is able to perform IO operations utilizing this phy as long as it
- * is currently part of a valid port.
- * This state is entered from the STARTING state.
- */
- SCI_BASE_PHY_STATE_READY,
-
- /**
- * This state indicates that the phy is in the process of being reset.
- * In this state no new IO operations are permitted on this phy.
- * This state is entered from the READY state.
- */
- SCI_BASE_PHY_STATE_RESETTING,
-
- /**
- * Simply the final state for the base phy state machine.
- */
- SCI_BASE_PHY_STATE_FINAL,
-};
-
-
-/**
- * enum scic_sds_phy_starting_substates -
- *
- *
- */
-enum scic_sds_phy_starting_substates {
- /**
- * Initial state
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL,
-
- /**
- * Wait state for the hardware OSSP event type notification
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN,
-
- /**
- * Wait state for the PHY speed notification
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN,
-
- /**
- * Wait state for the IAF Unsolicited frame notification
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF,
-
- /**
- * Wait state for the request to consume power
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER,
-
- /**
- * Wait state for request to consume power
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER,
-
- /**
- * Wait state for the SATA PHY notification
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN,
-
- /**
- * Wait for the SATA PHY speed notification
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN,
-
- /**
- * Wait state for the SIGNATURE FIS unsolicited frame notification
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF,
-
- /**
- * Exit state for this state machine
- */
- SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL,
-};
-
-struct scic_sds_port;
-struct scic_sds_controller;
-
-/**
- * This enumeration provides a named phy type for the state machine
- *
- *
- */
-enum scic_sds_phy_protocol {
- /**
- * This is an unknown phy type since there is either nothing on the other
- * end or we have not detected the phy type as yet.
- */
- SCIC_SDS_PHY_PROTOCOL_UNKNOWN,
-
- /**
- * This is a SAS PHY
- */
- SCIC_SDS_PHY_PROTOCOL_SAS,
-
- /**
- * This is a SATA PHY
- */
- SCIC_SDS_PHY_PROTOCOL_SATA,
-
- SCIC_SDS_MAX_PHY_PROTOCOLS
-};
-
-/**
- * struct scic_sds_phy - This structure contains or references all of the data
- * necessary to represent the core phy object and SCU harware protocol
- * engine.
- *
- *
- */
-struct scic_sds_phy {
- /**
- * This field contains the information for the base phy state machine.
- */
- struct sci_base_state_machine state_machine;
-
- /**
- * This field specifies the port object that owns/contains this phy.
- */
- struct scic_sds_port *owning_port;
-
- /**
- * This field indicates whether the phy supports 1.5 Gb/s, 3.0 Gb/s,
- * or 6.0 Gb/s operation.
- */
- enum sas_linkrate max_negotiated_speed;
-
- /**
- * This member specifies the protocol being utilized on this phy. This
- * field contains a legitamite value once the PHY has link trained with
- * a remote phy.
- */
- enum scic_sds_phy_protocol protocol;
-
- /**
- * This field specifies the index with which this phy is associated (0-3).
- */
- u8 phy_index;
-
- /**
- * This member indicates if this particular PHY has received a BCN while
- * it had no port assignement. This BCN will be reported once the phy is
- * assigned to a port.
- */
- bool bcn_received_while_port_unassigned;
-
- /**
- * This field indicates if this PHY is currently in the process of
- * link training (i.e. it has started OOB, but has yet to perform
- * IAF exchange/Signature FIS reception).
- */
- bool is_in_link_training;
-
- /**
- * This field contains a reference to the timer utilized in detecting
- * when a signature FIS timeout has occurred. The signature FIS is the
- * first FIS sent by an attached SATA device after OOB/SN.
- */
- void *sata_timeout_timer;
-
- const struct scic_sds_phy_state_handler *state_handlers;
-
- struct sci_base_state_machine starting_substate_machine;
-
- /**
- * This field is the pointer to the transport layer register for the SCU
- * hardware.
- */
- struct scu_transport_layer_registers __iomem *transport_layer_registers;
-
- /**
- * This field points to the link layer register set within the SCU.
- */
- struct scu_link_layer_registers __iomem *link_layer_registers;
-
-};
-
-typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *);
-typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32);
-typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32);
-typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *);
-
-/**
- * struct scic_sds_phy_state_handler -
- *
- *
- */
-struct scic_sds_phy_state_handler {
- /**
- * The start_handler specifies the method invoked when there is an
- * attempt to start a phy.
- */
- scic_sds_phy_handler_t start_handler;
-
- /**
- * The stop_handler specifies the method invoked when there is an
- * attempt to stop a phy.
- */
- scic_sds_phy_handler_t stop_handler;
-
- /**
- * The reset_handler specifies the method invoked when there is an
- * attempt to reset a phy.
- */
- scic_sds_phy_handler_t reset_handler;
-
- /**
- * The destruct_handler specifies the method invoked when attempting to
- * destruct a phy.
- */
- scic_sds_phy_handler_t destruct_handler;
-
- /**
- * The state handler for unsolicited frames received from the SCU hardware.
- */
- scic_sds_phy_frame_handler_t frame_handler;
-
- /**
- * The state handler for events received from the SCU hardware.
- */
- scic_sds_phy_event_handler_t event_handler;
-
- /**
- * The state handler for staggered spinup.
- */
- scic_sds_phy_power_handler_t consume_power_handler;
-
-};
-
-/**
- * scic_sds_phy_get_index() -
- *
- * This macro returns the phy index for the specified phy
- */
-#define scic_sds_phy_get_index(phy) \
- ((phy)->phy_index)
-
-/**
- * scic_sds_phy_get_controller() - This macro returns the controller for this
- * phy
- *
- *
- */
-#define scic_sds_phy_get_controller(phy) \
- (scic_sds_port_get_controller((phy)->owning_port))
-
-/**
- * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for
- * this phy object
- *
- *
- */
-#define scic_sds_phy_set_state_handlers(phy, handlers) \
- ((phy)->state_handlers = (handlers))
-
-/**
- * scic_sds_phy_set_base_state_handlers() -
- *
- * This macro set the base state handlers for the phy object.
- */
-#define scic_sds_phy_set_base_state_handlers(phy, state_id) \
- scic_sds_phy_set_state_handlers(\
- (phy), \
- &scic_sds_phy_state_handler_table[(state_id)] \
- )
-
-void scic_sds_phy_construct(
- struct scic_sds_phy *this_phy,
- struct scic_sds_port *owning_port,
- u8 phy_index);
-
-struct scic_sds_port *scic_sds_phy_get_port(
- struct scic_sds_phy *this_phy);
-
-void scic_sds_phy_set_port(
- struct scic_sds_phy *this_phy,
- struct scic_sds_port *owning_port);
-
-enum sci_status scic_sds_phy_initialize(
- struct scic_sds_phy *this_phy,
- struct scu_transport_layer_registers __iomem *transport_layer_registers,
- struct scu_link_layer_registers __iomem *link_layer_registers);
-
-enum sci_status scic_sds_phy_start(
- struct scic_sds_phy *this_phy);
-
-enum sci_status scic_sds_phy_stop(
- struct scic_sds_phy *this_phy);
-
-enum sci_status scic_sds_phy_reset(
- struct scic_sds_phy *this_phy);
-
-void scic_sds_phy_resume(
- struct scic_sds_phy *this_phy);
-
-void scic_sds_phy_setup_transport(
- struct scic_sds_phy *this_phy,
- u32 device_id);
-
-enum sci_status scic_sds_phy_event_handler(
- struct scic_sds_phy *this_phy,
- u32 event_code);
-
-enum sci_status scic_sds_phy_frame_handler(
- struct scic_sds_phy *this_phy,
- u32 frame_index);
-
-enum sci_status scic_sds_phy_consume_power_handler(
- struct scic_sds_phy *this_phy);
-
-void scic_sds_phy_get_sas_address(
- struct scic_sds_phy *this_phy,
- struct sci_sas_address *sas_address);
-
-void scic_sds_phy_get_attached_sas_address(
- struct scic_sds_phy *this_phy,
- struct sci_sas_address *sas_address);
-
-void scic_sds_phy_get_protocols(
- struct scic_sds_phy *sci_phy,
- struct scic_phy_proto *protocols);
-
-#endif /* _SCIC_SDS_PHY_H_ */
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c
index a9f3ce111b86..11b516a9a130 100644
--- a/drivers/scsi/isci/core/scic_sds_port.c
+++ b/drivers/scsi/isci/core/scic_sds_port.c
@@ -54,9 +54,7 @@
*/
#include "host.h"
-#include "scic_phy.h"
#include "scic_port.h"
-#include "scic_sds_phy.h"
#include "scic_sds_port.h"
#include "remote_device.h"
#include "remote_node_context.h"
diff --git a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h
index 56a40a712589..7fd161700475 100644
--- a/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h
+++ b/drivers/scsi/isci/core/scic_sds_port_configuration_agent.h
@@ -64,7 +64,6 @@
*/
#include "scic_sds_port.h"
-#include "scic_sds_phy.h"
struct scic_sds_controller;
struct scic_sds_port_configuration_agent;
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c
index 1134395c970e..b92d51f25481 100644
--- a/drivers/scsi/isci/phy.c
+++ b/drivers/scsi/isci/phy.c
@@ -56,12 +56,2219 @@
#include "isci.h"
#include "host.h"
#include "phy.h"
+#include "scu_event_codes.h"
#include "scic_port.h"
#include "scic_config_parameters.h"
+#include "timers.h"
-struct scic_sds_phy;
-extern enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy);
-extern enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy);
+/* Maximum arbitration wait time in micro-seconds */
+#define SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME (700)
+
+enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy)
+{
+ return sci_phy->max_negotiated_speed;
+}
+
+/*
+ * *****************************************************************************
+ * * SCIC SDS PHY Internal Methods
+ * ***************************************************************************** */
+
+/**
+ * This method will initialize the phy transport layer registers
+ * @sci_phy:
+ * @transport_layer_registers
+ *
+ * enum sci_status
+ */
+static enum sci_status scic_sds_phy_transport_layer_initialization(
+ struct scic_sds_phy *sci_phy,
+ struct scu_transport_layer_registers __iomem *transport_layer_registers)
+{
+ u32 tl_control;
+
+ sci_phy->transport_layer_registers = transport_layer_registers;
+
+ writel(SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX,
+ &sci_phy->transport_layer_registers->stp_rni);
+
+ /*
+ * Hardware team recommends that we enable the STP prefetch for all
+ * transports
+ */
+ tl_control = readl(&sci_phy->transport_layer_registers->control);
+ tl_control |= SCU_TLCR_GEN_BIT(STP_WRITE_DATA_PREFETCH);
+ writel(tl_control, &sci_phy->transport_layer_registers->control);
+
+ return SCI_SUCCESS;
+}
+
+/**
+ * This method will initialize the phy link layer registers
+ * @sci_phy:
+ * @link_layer_registers:
+ *
+ * enum sci_status
+ */
+static enum sci_status
+scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy,
+ struct scu_link_layer_registers __iomem *link_layer_registers)
+{
+ struct scic_sds_controller *scic =
+ sci_phy->owning_port->owning_controller;
+ int phy_idx = sci_phy->phy_index;
+ struct sci_phy_user_params *phy_user =
+ &scic->user_parameters.sds1.phys[phy_idx];
+ struct sci_phy_oem_params *phy_oem =
+ &scic->oem_parameters.sds1.phys[phy_idx];
+ u32 phy_configuration;
+ struct scic_phy_cap phy_cap;
+ u32 parity_check = 0;
+ u32 parity_count = 0;
+ u32 llctl, link_rate;
+ u32 clksm_value = 0;
+
+ sci_phy->link_layer_registers = link_layer_registers;
+
+ /* Set our IDENTIFY frame data */
+ #define SCI_END_DEVICE 0x01
+
+ writel(SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) |
+ SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) |
+ SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) |
+ SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) |
+ SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE),
+ &sci_phy->link_layer_registers->transmit_identification);
+
+ /* Write the device SAS Address */
+ writel(0xFEDCBA98,
+ &sci_phy->link_layer_registers->sas_device_name_high);
+ writel(phy_idx, &sci_phy->link_layer_registers->sas_device_name_low);
+
+ /* Write the source SAS Address */
+ writel(phy_oem->sas_address.high,
+ &sci_phy->link_layer_registers->source_sas_address_high);
+ writel(phy_oem->sas_address.low,
+ &sci_phy->link_layer_registers->source_sas_address_low);
+
+ /* Clear and Set the PHY Identifier */
+ writel(0, &sci_phy->link_layer_registers->identify_frame_phy_id);
+ writel(SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx),
+ &sci_phy->link_layer_registers->identify_frame_phy_id);
+
+ /* Change the initial state of the phy configuration register */
+ phy_configuration =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+
+ /* Hold OOB state machine in reset */
+ phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
+ writel(phy_configuration,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ /* Configure the SNW capabilities */
+ phy_cap.all = 0;
+ phy_cap.start = 1;
+ phy_cap.gen3_no_ssc = 1;
+ phy_cap.gen2_no_ssc = 1;
+ phy_cap.gen1_no_ssc = 1;
+ if (scic->oem_parameters.sds1.controller.do_enable_ssc == true) {
+ phy_cap.gen3_ssc = 1;
+ phy_cap.gen2_ssc = 1;
+ phy_cap.gen1_ssc = 1;
+ }
+
+ /*
+ * The SAS specification indicates that the phy_capabilities that
+ * are transmitted shall have an even parity. Calculate the parity. */
+ parity_check = phy_cap.all;
+ while (parity_check != 0) {
+ if (parity_check & 0x1)
+ parity_count++;
+ parity_check >>= 1;
+ }
+
+ /*
+ * If parity indicates there are an odd number of bits set, then
+ * set the parity bit to 1 in the phy capabilities. */
+ if ((parity_count % 2) != 0)
+ phy_cap.parity = 1;
+
+ writel(phy_cap.all, &sci_phy->link_layer_registers->phy_capabilities);
+
+ /* Set the enable spinup period but disable the ability to send
+ * notify enable spinup
+ */
+ writel(SCU_ENSPINUP_GEN_VAL(COUNT,
+ phy_user->notify_enable_spin_up_insertion_frequency),
+ &sci_phy->link_layer_registers->notify_enable_spinup_control);
+
+ /* Write the ALIGN Insertion Ferequency for connected phy and
+ * inpendent of connected state
+ */
+ clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED,
+ phy_user->in_connection_align_insertion_frequency);
+
+ clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL,
+ phy_user->align_insertion_frequency);
+
+ writel(clksm_value, &sci_phy->link_layer_registers->clock_skew_management);
+
+ /* @todo Provide a way to write this register correctly */
+ writel(0x02108421,
+ &sci_phy->link_layer_registers->afe_lookup_table_control);
+
+ llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT,
+ (u8)scic->user_parameters.sds1.no_outbound_task_timeout);
+
+ switch(phy_user->max_speed_generation) {
+ case SCIC_SDS_PARM_GEN3_SPEED:
+ link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3;
+ break;
+ case SCIC_SDS_PARM_GEN2_SPEED:
+ link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2;
+ break;
+ default:
+ link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1;
+ break;
+ }
+ llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate);
+ writel(llctl, &sci_phy->link_layer_registers->link_layer_control);
+
+ if (is_a0() || is_a2()) {
+ /* Program the max ARB time for the PHY to 700us so we inter-operate with
+ * the PMC expander which shuts down PHYs if the expander PHY generates too
+ * many breaks. This time value will guarantee that the initiator PHY will
+ * generate the break.
+ */
+ writel(SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME,
+ &sci_phy->link_layer_registers->maximum_arbitration_wait_timer_timeout);
+ }
+
+ /*
+ * Set the link layer hang detection to 500ms (0x1F4) from its default
+ * value of 128ms. Max value is 511 ms.
+ */
+ writel(0x1F4, &sci_phy->link_layer_registers->link_layer_hang_detection_timeout);
+
+ /* We can exit the initial state to the stopped state */
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STOPPED);
+
+ return SCI_SUCCESS;
+}
+
+/**
+ * This function will handle the sata SIGNATURE FIS timeout condition. It will
+ * restart the starting substate machine since we dont know what has actually
+ * happening.
+ */
+static void scic_sds_phy_sata_timeout(void *phy)
+{
+ struct scic_sds_phy *sci_phy = phy;
+
+ dev_dbg(sciphy_to_dev(sci_phy),
+ "%s: SCIC SDS Phy 0x%p did not receive signature fis before "
+ "timeout.\n",
+ __func__,
+ sci_phy);
+
+ sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
+
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STARTING);
+}
+
+/**
+ * This method returns the port currently containing this phy. If the phy is
+ * currently contained by the dummy port, then the phy is considered to not
+ * be part of a port.
+ * @sci_phy: This parameter specifies the phy for which to retrieve the
+ * containing port.
+ *
+ * This method returns a handle to a port that contains the supplied phy.
+ * NULL This value is returned if the phy is not part of a real
+ * port (i.e. it's contained in the dummy port). !NULL All other
+ * values indicate a handle/pointer to the port containing the phy.
+ */
+struct scic_sds_port *scic_sds_phy_get_port(
+ struct scic_sds_phy *sci_phy)
+{
+ if (scic_sds_port_get_index(sci_phy->owning_port) == SCIC_SDS_DUMMY_PORT)
+ return NULL;
+
+ return sci_phy->owning_port;
+}
+
+/**
+ * This method will assign a port to the phy object.
+ * @out]: sci_phy This parameter specifies the phy for which to assign a port
+ * object.
+ *
+ *
+ */
+void scic_sds_phy_set_port(
+ struct scic_sds_phy *sci_phy,
+ struct scic_sds_port *sci_port)
+{
+ sci_phy->owning_port = sci_port;
+
+ if (sci_phy->bcn_received_while_port_unassigned) {
+ sci_phy->bcn_received_while_port_unassigned = false;
+ scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy);
+ }
+}
+
+/**
+ * This method will initialize the constructed phy
+ * @sci_phy:
+ * @link_layer_registers:
+ *
+ * enum sci_status
+ */
+enum sci_status scic_sds_phy_initialize(
+ struct scic_sds_phy *sci_phy,
+ struct scu_transport_layer_registers __iomem *transport_layer_registers,
+ struct scu_link_layer_registers __iomem *link_layer_registers)
+{
+ struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
+ struct isci_host *ihost = scic_to_ihost(scic);
+
+ /* Create the SIGNATURE FIS Timeout timer for this phy */
+ sci_phy->sata_timeout_timer =
+ isci_timer_create(
+ ihost,
+ sci_phy,
+ scic_sds_phy_sata_timeout);
+
+ /* Perfrom the initialization of the TL hardware */
+ scic_sds_phy_transport_layer_initialization(
+ sci_phy,
+ transport_layer_registers);
+
+ /* Perofrm the initialization of the PE hardware */
+ scic_sds_phy_link_layer_initialization(sci_phy, link_layer_registers);
+
+ /*
+ * There is nothing that needs to be done in this state just
+ * transition to the stopped state. */
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STOPPED);
+
+ return SCI_SUCCESS;
+}
+
+/**
+ * This method assigns the direct attached device ID for this phy.
+ *
+ * @sci_phy The phy for which the direct attached device id is to
+ * be assigned.
+ * @device_id The direct attached device ID to assign to the phy.
+ * This will either be the RNi for the device or an invalid RNi if there
+ * is no current device assigned to the phy.
+ */
+void scic_sds_phy_setup_transport(
+ struct scic_sds_phy *sci_phy,
+ u32 device_id)
+{
+ u32 tl_control;
+
+ writel(device_id, &sci_phy->transport_layer_registers->stp_rni);
+
+ /*
+ * The read should guarantee that the first write gets posted
+ * before the next write
+ */
+ tl_control = readl(&sci_phy->transport_layer_registers->control);
+ tl_control |= SCU_TLCR_GEN_BIT(CLEAR_TCI_NCQ_MAPPING_TABLE);
+ writel(tl_control, &sci_phy->transport_layer_registers->control);
+}
+
+/**
+ *
+ * @sci_phy: The phy object to be suspended.
+ *
+ * This function will perform the register reads/writes to suspend the SCU
+ * hardware protocol engine. none
+ */
+static void scic_sds_phy_suspend(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 scu_sas_pcfg_value;
+
+ scu_sas_pcfg_value =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
+ writel(scu_sas_pcfg_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ scic_sds_phy_setup_transport(
+ sci_phy,
+ SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
+}
+
+void scic_sds_phy_resume(struct scic_sds_phy *sci_phy)
+{
+ u32 scu_sas_pcfg_value;
+
+ scu_sas_pcfg_value =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE);
+ writel(scu_sas_pcfg_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+}
+
+void scic_sds_phy_get_sas_address(struct scic_sds_phy *sci_phy,
+ struct sci_sas_address *sas_address)
+{
+ sas_address->high = readl(&sci_phy->link_layer_registers->source_sas_address_high);
+ sas_address->low = readl(&sci_phy->link_layer_registers->source_sas_address_low);
+}
+
+void scic_sds_phy_get_attached_sas_address(struct scic_sds_phy *sci_phy,
+ struct sci_sas_address *sas_address)
+{
+ struct sas_identify_frame *iaf;
+ struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
+
+ iaf = &iphy->frame_rcvd.iaf;
+ memcpy(sas_address, iaf->sas_addr, SAS_ADDR_SIZE);
+}
+
+void scic_sds_phy_get_protocols(struct scic_sds_phy *sci_phy,
+ struct scic_phy_proto *protocols)
+{
+ protocols->all =
+ (u16)(readl(&sci_phy->
+ link_layer_registers->transmit_identification) &
+ 0x0000FFFF);
+}
+
+/**
+ * This method will attempt to start the phy object. This request is only valid
+ * when the phy is in the stopped state
+ * @sci_phy:
+ *
+ * enum sci_status
+ */
+enum sci_status scic_sds_phy_start(struct scic_sds_phy *sci_phy)
+{
+ return sci_phy->state_handlers->start_handler(sci_phy);
+}
+
+/**
+ * This method will attempt to stop the phy object.
+ * @sci_phy:
+ *
+ * enum sci_status SCI_SUCCESS if the phy is going to stop SCI_INVALID_STATE
+ * if the phy is not in a valid state to stop
+ */
+enum sci_status scic_sds_phy_stop(struct scic_sds_phy *sci_phy)
+{
+ return sci_phy->state_handlers->stop_handler(sci_phy);
+}
+
+/**
+ * This method will attempt to reset the phy. This request is only valid when
+ * the phy is in an ready state
+ * @sci_phy:
+ *
+ * enum sci_status
+ */
+enum sci_status scic_sds_phy_reset(
+ struct scic_sds_phy *sci_phy)
+{
+ return sci_phy->state_handlers->reset_handler(sci_phy);
+}
+
+/**
+ * This method will process the event code received.
+ * @sci_phy:
+ * @event_code:
+ *
+ * enum sci_status
+ */
+enum sci_status scic_sds_phy_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ return sci_phy->state_handlers->event_handler(sci_phy, event_code);
+}
+
+/**
+ * This method will process the frame index received.
+ * @sci_phy:
+ * @frame_index:
+ *
+ * enum sci_status
+ */
+enum sci_status scic_sds_phy_frame_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 frame_index)
+{
+ return sci_phy->state_handlers->frame_handler(sci_phy, frame_index);
+}
+
+/**
+ * This method will give the phy permission to consume power
+ * @sci_phy:
+ *
+ * enum sci_status
+ */
+enum sci_status scic_sds_phy_consume_power_handler(
+ struct scic_sds_phy *sci_phy)
+{
+ return sci_phy->state_handlers->consume_power_handler(sci_phy);
+}
+
+/*
+ * *****************************************************************************
+ * * SCIC SDS PHY HELPER FUNCTIONS
+ * ***************************************************************************** */
+
+
+/**
+ *
+ * @sci_phy: The phy object that received SAS PHY DETECTED.
+ *
+ * This method continues the link training for the phy as if it were a SAS PHY
+ * instead of a SATA PHY. This is done because the completion queue had a SAS
+ * PHY DETECTED event when the state machine was expecting a SATA PHY event.
+ * none
+ */
+static void scic_sds_phy_start_sas_link_training(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 phy_control;
+
+ phy_control =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ phy_control |= SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD);
+ writel(phy_control,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ sci_base_state_machine_change_state(
+ &sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
+ );
+
+ sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SAS;
+}
+
+/**
+ *
+ * @sci_phy: The phy object that received a SATA SPINUP HOLD event
+ *
+ * This method continues the link training for the phy as if it were a SATA PHY
+ * instead of a SAS PHY. This is done because the completion queue had a SATA
+ * SPINUP HOLD event when the state machine was expecting a SAS PHY event. none
+ */
+static void scic_sds_phy_start_sata_link_training(
+ struct scic_sds_phy *sci_phy)
+{
+ sci_base_state_machine_change_state(
+ &sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
+ );
+
+ sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
+}
+
+/**
+ * scic_sds_phy_complete_link_training - perform processing common to
+ * all protocols upon completion of link training.
+ * @sci_phy: This parameter specifies the phy object for which link training
+ * has completed.
+ * @max_link_rate: This parameter specifies the maximum link rate to be
+ * associated with this phy.
+ * @next_state: This parameter specifies the next state for the phy's starting
+ * sub-state machine.
+ *
+ */
+static void scic_sds_phy_complete_link_training(
+ struct scic_sds_phy *sci_phy,
+ enum sas_linkrate max_link_rate,
+ u32 next_state)
+{
+ sci_phy->max_negotiated_speed = max_link_rate;
+
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ next_state);
+}
+
+static void scic_sds_phy_restart_starting_state(
+ struct scic_sds_phy *sci_phy)
+{
+ /* Stop the current substate machine */
+ sci_base_state_machine_stop(&sci_phy->starting_substate_machine);
+
+ /* Re-enter the base state machine starting state */
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STARTING);
+}
+
+/* ****************************************************************************
+ * SCIC SDS PHY general handlers
+ ************************************************************************** */
+static enum sci_status scic_sds_phy_starting_substate_general_stop_handler(
+ struct scic_sds_phy *phy)
+{
+ sci_base_state_machine_stop(&phy->starting_substate_machine);
+
+ sci_base_state_machine_change_state(&phy->state_machine,
+ SCI_BASE_PHY_STATE_STOPPED);
+
+ return SCI_SUCCESS;
+}
+
+/*
+ * *****************************************************************************
+ * * SCIC SDS PHY EVENT_HANDLERS
+ * ***************************************************************************** */
+
+/**
+ *
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. -
+ * decode the event - sas phy detected causes a state transition to the wait
+ * for speed event notification. - any other events log a warning message and
+ * set a failure status enum sci_status SCI_SUCCESS on any valid event notification
+ * SCI_FAILURE on any unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_ossp_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_SAS_PHY_DETECTED:
+ scic_sds_phy_start_sas_link_training(sci_phy);
+ sci_phy->is_in_link_training = true;
+ break;
+
+ case SCU_EVENT_SATA_SPINUP_HOLD:
+ scic_sds_phy_start_sata_link_training(sci_phy);
+ sci_phy->is_in_link_training = true;
+ break;
+
+ default:
+ dev_dbg(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ *
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. -
+ * decode the event - sas phy detected returns us back to this state. - speed
+ * event detected causes a state transition to the wait for iaf. - identify
+ * timeout is an un-expected event and the state machine is restarted. - link
+ * failure events restart the starting state machine - any other events log a
+ * warning message and set a failure status enum sci_status SCI_SUCCESS on any valid
+ * event notification SCI_FAILURE on any unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_SAS_PHY_DETECTED:
+ /*
+ * Why is this being reported again by the controller?
+ * We would re-enter this state so just stay here */
+ break;
+
+ case SCU_EVENT_SAS_15:
+ case SCU_EVENT_SAS_15_SSC:
+ scic_sds_phy_complete_link_training(
+ sci_phy,
+ SAS_LINK_RATE_1_5_GBPS,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF);
+ break;
+
+ case SCU_EVENT_SAS_30:
+ case SCU_EVENT_SAS_30_SSC:
+ scic_sds_phy_complete_link_training(
+ sci_phy,
+ SAS_LINK_RATE_3_0_GBPS,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF);
+ break;
+
+ case SCU_EVENT_SAS_60:
+ case SCU_EVENT_SAS_60_SSC:
+ scic_sds_phy_complete_link_training(
+ sci_phy,
+ SAS_LINK_RATE_6_0_GBPS,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF);
+ break;
+
+ case SCU_EVENT_SATA_SPINUP_HOLD:
+ /*
+ * We were doing SAS PHY link training and received a SATA PHY event
+ * continue OOB/SN as if this were a SATA PHY */
+ scic_sds_phy_start_sata_link_training(sci_phy);
+ break;
+
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ *
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. -
+ * decode the event - sas phy detected event backs up the state machine to the
+ * await speed notification. - identify timeout is an un-expected event and the
+ * state machine is restarted. - link failure events restart the starting state
+ * machine - any other events log a warning message and set a failure status
+ * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any
+ * unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_SAS_PHY_DETECTED:
+ /* Backup the state machine */
+ scic_sds_phy_start_sas_link_training(sci_phy);
+ break;
+
+ case SCU_EVENT_SATA_SPINUP_HOLD:
+ /*
+ * We were doing SAS PHY link training and received a SATA PHY event
+ * continue OOB/SN as if this were a SATA PHY */
+ scic_sds_phy_start_sata_link_training(sci_phy);
+ break;
+
+ case SCU_EVENT_RECEIVED_IDENTIFY_TIMEOUT:
+ case SCU_EVENT_LINK_FAILURE:
+ case SCU_EVENT_HARD_RESET_RECEIVED:
+ /* Start the oob/sn state machine over again */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ *
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_POWER. -
+ * decode the event - link failure events restart the starting state machine -
+ * any other events log a warning message and set a failure status enum sci_status
+ * SCI_SUCCESS on a link failure event SCI_FAILURE on any unexpected event
+ * notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sas_power_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received unexpected "
+ "event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ *
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. -
+ * decode the event - link failure events restart the starting state machine -
+ * sata spinup hold events are ignored since they are expected - any other
+ * events log a warning message and set a failure status enum sci_status SCI_SUCCESS
+ * on a link failure event SCI_FAILURE on any unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sata_power_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ case SCU_EVENT_SATA_SPINUP_HOLD:
+ /* These events are received every 10ms and are expected while in this state */
+ break;
+
+ case SCU_EVENT_SAS_PHY_DETECTED:
+ /*
+ * There has been a change in the phy type before OOB/SN for the
+ * SATA finished start down the SAS link traning path. */
+ scic_sds_phy_start_sas_link_training(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ * scic_sds_phy_starting_substate_await_sata_phy_event_handler -
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. -
+ * decode the event - link failure events restart the starting state machine -
+ * sata spinup hold events are ignored since they are expected - sata phy
+ * detected event change to the wait speed event - any other events log a
+ * warning message and set a failure status enum sci_status SCI_SUCCESS on a link
+ * failure event SCI_FAILURE on any unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sata_phy_event_handler(
+ struct scic_sds_phy *sci_phy, u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ case SCU_EVENT_SATA_SPINUP_HOLD:
+ /* These events might be received since we dont know how many may be in
+ * the completion queue while waiting for power
+ */
+ break;
+
+ case SCU_EVENT_SATA_PHY_DETECTED:
+ sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_SATA;
+
+ /* We have received the SATA PHY notification change state */
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
+ break;
+
+ case SCU_EVENT_SAS_PHY_DETECTED:
+ /* There has been a change in the phy type before OOB/SN for the
+ * SATA finished start down the SAS link traning path.
+ */
+ scic_sds_phy_start_sas_link_training(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ *
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN.
+ * - decode the event - sata phy detected returns us back to this state. -
+ * speed event detected causes a state transition to the wait for signature. -
+ * link failure events restart the starting state machine - any other events
+ * log a warning message and set a failure status enum sci_status SCI_SUCCESS on any
+ * valid event notification SCI_FAILURE on any unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sata_speed_event_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_SATA_PHY_DETECTED:
+ /*
+ * The hardware reports multiple SATA PHY detected events
+ * ignore the extras */
+ break;
+
+ case SCU_EVENT_SATA_15:
+ case SCU_EVENT_SATA_15_SSC:
+ scic_sds_phy_complete_link_training(
+ sci_phy,
+ SAS_LINK_RATE_1_5_GBPS,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
+ break;
+
+ case SCU_EVENT_SATA_30:
+ case SCU_EVENT_SATA_30_SSC:
+ scic_sds_phy_complete_link_training(
+ sci_phy,
+ SAS_LINK_RATE_3_0_GBPS,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
+ break;
+
+ case SCU_EVENT_SATA_60:
+ case SCU_EVENT_SATA_60_SSC:
+ scic_sds_phy_complete_link_training(
+ sci_phy,
+ SAS_LINK_RATE_6_0_GBPS,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
+ break;
+
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ case SCU_EVENT_SAS_PHY_DETECTED:
+ /*
+ * There has been a change in the phy type before OOB/SN for the
+ * SATA finished start down the SAS link traning path. */
+ scic_sds_phy_start_sas_link_training(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+/**
+ * scic_sds_phy_starting_substate_await_sig_fis_event_handler -
+ * @phy: This struct scic_sds_phy object which has received an event.
+ * @event_code: This is the event code which the phy object is to decode.
+ *
+ * This method is called when an event notification is received for the phy
+ * object when in the state SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. -
+ * decode the event - sas phy detected event backs up the state machine to the
+ * await speed notification. - identify timeout is an un-expected event and the
+ * state machine is restarted. - link failure events restart the starting state
+ * machine - any other events log a warning message and set a failure status
+ * enum sci_status SCI_SUCCESS on any valid event notification SCI_FAILURE on any
+ * unexpected event notifation
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_event_handler(
+ struct scic_sds_phy *sci_phy, u32 event_code)
+{
+ u32 result = SCI_SUCCESS;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_SATA_PHY_DETECTED:
+ /* Backup the state machine */
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
+ break;
+
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ scic_sds_phy_restart_starting_state(sci_phy);
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected event_code %x\n",
+ __func__,
+ event_code);
+
+ result = SCI_FAILURE;
+ break;
+ }
+
+ return result;
+}
+
+
+/*
+ * *****************************************************************************
+ * * SCIC SDS PHY FRAME_HANDLERS
+ * ***************************************************************************** */
+
+/**
+ *
+ * @phy: This is struct scic_sds_phy object which is being requested to decode the
+ * frame data.
+ * @frame_index: This is the index of the unsolicited frame which was received
+ * for this phy.
+ *
+ * This method decodes the unsolicited frame when the struct scic_sds_phy is in the
+ * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Get the UF Header - If the UF
+ * is an IAF - Copy IAF data to local phy object IAF data buffer. - Change
+ * starting substate to wait power. - else - log warning message of unexpected
+ * unsolicted frame - release frame buffer enum sci_status SCI_SUCCESS
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_iaf_uf_frame_handler(
+ struct scic_sds_phy *sci_phy, u32 frame_index)
+{
+ enum sci_status result;
+ u32 *frame_words;
+ struct sas_identify_frame iaf;
+ struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
+
+ result = scic_sds_unsolicited_frame_control_get_header(
+ &(scic_sds_phy_get_controller(sci_phy)->uf_control),
+ frame_index,
+ (void **)&frame_words);
+
+ if (result != SCI_SUCCESS)
+ return result;
+
+ sci_swab32_cpy(&iaf, frame_words, sizeof(iaf) / sizeof(u32));
+ if (iaf.frame_type == 0) {
+ u32 state;
+
+ memcpy(&iphy->frame_rcvd.iaf, &iaf, sizeof(iaf));
+ if (iaf.smp_tport) {
+ /* We got the IAF for an expander PHY go to the final
+ * state since there are no power requirements for
+ * expander phys.
+ */
+ state = SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL;
+ } else {
+ /* We got the IAF we can now go to the await spinup
+ * semaphore state
+ */
+ state = SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER;
+ }
+ sci_base_state_machine_change_state(
+ &sci_phy->starting_substate_machine,
+ state);
+ result = SCI_SUCCESS;
+ } else
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected frame id %x\n",
+ __func__,
+ frame_index);
+
+ scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
+ frame_index);
+
+ return result;
+}
+
+/**
+ *
+ * @phy: This is struct scic_sds_phy object which is being requested to decode the
+ * frame data.
+ * @frame_index: This is the index of the unsolicited frame which was received
+ * for this phy.
+ *
+ * This method decodes the unsolicited frame when the struct scic_sds_phy is in the
+ * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Get the UF Header - If
+ * the UF is an SIGNATURE FIS - Copy IAF data to local phy object SIGNATURE FIS
+ * data buffer. - else - log warning message of unexpected unsolicted frame -
+ * release frame buffer enum sci_status SCI_SUCCESS Must decode the SIGNATURE FIS
+ * data
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sig_fis_frame_handler(
+ struct scic_sds_phy *sci_phy,
+ u32 frame_index)
+{
+ enum sci_status result;
+ struct dev_to_host_fis *frame_header;
+ u32 *fis_frame_data;
+ struct isci_phy *iphy = sci_phy_to_iphy(sci_phy);
+
+ result = scic_sds_unsolicited_frame_control_get_header(
+ &(scic_sds_phy_get_controller(sci_phy)->uf_control),
+ frame_index,
+ (void **)&frame_header);
+
+ if (result != SCI_SUCCESS)
+ return result;
+
+ if ((frame_header->fis_type == FIS_REGD2H) &&
+ !(frame_header->status & ATA_BUSY)) {
+ scic_sds_unsolicited_frame_control_get_buffer(
+ &(scic_sds_phy_get_controller(sci_phy)->uf_control),
+ frame_index,
+ (void **)&fis_frame_data);
+
+ scic_sds_controller_copy_sata_response(&iphy->frame_rcvd.fis,
+ frame_header,
+ fis_frame_data);
+
+ /* got IAF we can now go to the await spinup semaphore state */
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
+
+ result = SCI_SUCCESS;
+ } else
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: PHY starting substate machine received "
+ "unexpected frame id %x\n",
+ __func__,
+ frame_index);
+
+ /* Regardless of the result we are done with this frame with it */
+ scic_sds_controller_release_frame(scic_sds_phy_get_controller(sci_phy),
+ frame_index);
+
+ return result;
+}
+
+/*
+ * *****************************************************************************
+ * * SCIC SDS PHY POWER_HANDLERS
+ * ***************************************************************************** */
+
+/*
+ * This method is called by the struct scic_sds_controller when the phy object is
+ * granted power. - The notify enable spinups are turned on for this phy object
+ * - The phy state machine is transitioned to the
+ * SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. enum sci_status SCI_SUCCESS
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sas_power_consume_power_handler(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 enable_spinup;
+
+ enable_spinup = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
+ enable_spinup |= SCU_ENSPINUP_GEN_BIT(ENABLE);
+ writel(enable_spinup, &sci_phy->link_layer_registers->notify_enable_spinup_control);
+
+ /* Change state to the final state this substate machine has run to completion */
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
+
+ return SCI_SUCCESS;
+}
+
+/*
+ * This method is called by the struct scic_sds_controller when the phy object is
+ * granted power. - The phy state machine is transitioned to the
+ * SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. enum sci_status SCI_SUCCESS
+ */
+static enum sci_status scic_sds_phy_starting_substate_await_sata_power_consume_power_handler(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 scu_sas_pcfg_value;
+
+ /* Release the spinup hold state and reset the OOB state machine */
+ scu_sas_pcfg_value =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ scu_sas_pcfg_value &=
+ ~(SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD) | SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE));
+ scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
+ writel(scu_sas_pcfg_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ /* Now restart the OOB operation */
+ scu_sas_pcfg_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
+ scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
+ writel(scu_sas_pcfg_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ /* Change state to the final state this substate machine has run to completion */
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
+
+ return SCI_SUCCESS;
+}
+
+static enum sci_status default_phy_handler(struct scic_sds_phy *sci_phy,
+ const char *func)
+{
+ dev_dbg(sciphy_to_dev(sci_phy),
+ "%s: in wrong state: %d\n", func,
+ sci_base_state_machine_get_state(&sci_phy->state_machine));
+ return SCI_FAILURE_INVALID_STATE;
+}
+
+static enum sci_status
+scic_sds_phy_default_start_handler(struct scic_sds_phy *sci_phy)
+{
+ return default_phy_handler(sci_phy, __func__);
+}
+
+static enum sci_status
+scic_sds_phy_default_stop_handler(struct scic_sds_phy *sci_phy)
+{
+ return default_phy_handler(sci_phy, __func__);
+}
+
+static enum sci_status
+scic_sds_phy_default_reset_handler(struct scic_sds_phy *sci_phy)
+{
+ return default_phy_handler(sci_phy, __func__);
+}
+
+static enum sci_status
+scic_sds_phy_default_destroy_handler(struct scic_sds_phy *sci_phy)
+{
+ return default_phy_handler(sci_phy, __func__);
+}
+
+static enum sci_status
+scic_sds_phy_default_frame_handler(struct scic_sds_phy *sci_phy,
+ u32 frame_index)
+{
+ struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
+
+ default_phy_handler(sci_phy, __func__);
+ scic_sds_controller_release_frame(scic, frame_index);
+
+ return SCI_FAILURE_INVALID_STATE;
+}
+
+static enum sci_status
+scic_sds_phy_default_event_handler(struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ return default_phy_handler(sci_phy, __func__);
+}
+
+static enum sci_status
+scic_sds_phy_default_consume_power_handler(struct scic_sds_phy *sci_phy)
+{
+ return default_phy_handler(sci_phy, __func__);
+}
+
+
+
+static const struct scic_sds_phy_state_handler scic_sds_phy_starting_substate_handler_table[] = {
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_default_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_ossp_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_sas_phy_speed_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_default_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_starting_substate_await_iaf_uf_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_iaf_uf_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_sas_power_event_handler,
+ .consume_power_handler = scic_sds_phy_starting_substate_await_sas_power_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_sata_power_event_handler,
+ .consume_power_handler = scic_sds_phy_starting_substate_await_sata_power_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_sata_phy_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_sata_speed_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_starting_substate_await_sig_fis_frame_handler,
+ .event_handler = scic_sds_phy_starting_substate_await_sig_fis_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_starting_substate_general_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_default_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ }
+};
+
+/**
+ * scic_sds_phy_set_starting_substate_handlers() -
+ *
+ * This macro sets the starting substate handlers by state_id
+ */
+#define scic_sds_phy_set_starting_substate_handlers(phy, state_id) \
+ scic_sds_phy_set_state_handlers(\
+ (phy), \
+ &scic_sds_phy_starting_substate_handler_table[(state_id)] \
+ )
+
+/*
+ * ****************************************************************************
+ * * PHY STARTING SUBSTATE METHODS
+ * **************************************************************************** */
+
+/**
+ * scic_sds_phy_starting_initial_substate_enter -
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL. - The initial state
+ * handlers are put in place for the struct scic_sds_phy object. - The state is
+ * changed to the wait phy type event notification. none
+ */
+static void scic_sds_phy_starting_initial_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
+
+ /* This is just an temporary state go off to the starting state */
+ sci_base_state_machine_change_state(&sci_phy->starting_substate_machine,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_PHY_TYPE_EN. - Set the
+ * struct scic_sds_phy object state handlers for this state. none
+ */
+static void scic_sds_phy_starting_await_ossp_en_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SPEED_EN. - Set the
+ * struct scic_sds_phy object state handlers for this state. none
+ */
+static void scic_sds_phy_starting_await_sas_speed_en_substate_enter(
+ void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF. - Set the
+ * struct scic_sds_phy object state handlers for this state. none
+ */
+static void scic_sds_phy_starting_await_iaf_uf_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Set the
+ * struct scic_sds_phy object state handlers for this state. - Add this phy object to
+ * the power control queue none
+ */
+static void scic_sds_phy_starting_await_sas_power_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER
+ );
+
+ scic_sds_controller_power_control_queue_insert(
+ scic_sds_phy_get_controller(sci_phy),
+ sci_phy
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on exiting
+ * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER. - Remove the
+ * struct scic_sds_phy object from the power control queue. none
+ */
+static void scic_sds_phy_starting_await_sas_power_substate_exit(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_controller_power_control_queue_remove(
+ scic_sds_phy_get_controller(sci_phy), sci_phy
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Set the
+ * struct scic_sds_phy object state handlers for this state. - Add this phy object to
+ * the power control queue none
+ */
+static void scic_sds_phy_starting_await_sata_power_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy, SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER
+ );
+
+ scic_sds_controller_power_control_queue_insert(
+ scic_sds_phy_get_controller(sci_phy),
+ sci_phy
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on exiting
+ * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER. - Remove the
+ * struct scic_sds_phy object from the power control queue. none
+ */
+static void scic_sds_phy_starting_await_sata_power_substate_exit(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_controller_power_control_queue_remove(
+ scic_sds_phy_get_controller(sci_phy),
+ sci_phy
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This function will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN. - Set the
+ * struct scic_sds_phy object state handlers for this state. none
+ */
+static void scic_sds_phy_starting_await_sata_phy_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN);
+
+ isci_timer_start(sci_phy->sata_timeout_timer,
+ SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy
+ * on exiting
+ * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
+ * that was started on entry to await sata phy event notification none
+ */
+static inline void scic_sds_phy_starting_await_sata_phy_substate_exit(
+ void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ isci_timer_stop(sci_phy->sata_timeout_timer);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - Set the
+ * struct scic_sds_phy object state handlers for this state. none
+ */
+static void scic_sds_phy_starting_await_sata_speed_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN);
+
+ isci_timer_start(sci_phy->sata_timeout_timer,
+ SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This function will perform the actions required by the
+ * struct scic_sds_phy on exiting
+ * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN. - stop the timer
+ * that was started on entry to await sata phy event notification none
+ */
+static inline void scic_sds_phy_starting_await_sata_speed_substate_exit(
+ void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ isci_timer_stop(sci_phy->sata_timeout_timer);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This function will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Set the
+ * struct scic_sds_phy object state handlers for this state.
+ * - Start the SIGNATURE FIS
+ * timeout timer none
+ */
+static void scic_sds_phy_starting_await_sig_fis_uf_substate_enter(void *object)
+{
+ bool continue_to_ready_state;
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(
+ sci_phy,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF);
+
+ continue_to_ready_state = scic_sds_port_link_detected(
+ sci_phy->owning_port,
+ sci_phy);
+
+ if (continue_to_ready_state) {
+ /*
+ * Clear the PE suspend condition so we can actually
+ * receive SIG FIS
+ * The hardware will not respond to the XRDY until the PE
+ * suspend condition is cleared.
+ */
+ scic_sds_phy_resume(sci_phy);
+
+ isci_timer_start(sci_phy->sata_timeout_timer,
+ SCIC_SDS_SIGNATURE_FIS_TIMEOUT);
+ } else
+ sci_phy->is_in_link_training = false;
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This function will perform the actions required by the
+ * struct scic_sds_phy on exiting
+ * the SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF. - Stop the SIGNATURE
+ * FIS timeout timer. none
+ */
+static inline void scic_sds_phy_starting_await_sig_fis_uf_substate_exit(
+ void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ isci_timer_stop(sci_phy->sata_timeout_timer);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL. - Set the struct scic_sds_phy
+ * object state handlers for this state. - Change base state machine to the
+ * ready state. none
+ */
+static void scic_sds_phy_starting_final_substate_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_starting_substate_handlers(sci_phy,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL);
+
+ /* State machine has run to completion so exit out and change
+ * the base state machine to the ready state
+ */
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_READY);
+}
+
+/* --------------------------------------------------------------------------- */
+
+static const struct sci_base_state scic_sds_phy_starting_substates[] = {
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL] = {
+ .enter_state = scic_sds_phy_starting_initial_substate_enter,
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN] = {
+ .enter_state = scic_sds_phy_starting_await_ossp_en_substate_enter,
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN] = {
+ .enter_state = scic_sds_phy_starting_await_sas_speed_en_substate_enter,
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF] = {
+ .enter_state = scic_sds_phy_starting_await_iaf_uf_substate_enter,
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER] = {
+ .enter_state = scic_sds_phy_starting_await_sas_power_substate_enter,
+ .exit_state = scic_sds_phy_starting_await_sas_power_substate_exit,
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER] = {
+ .enter_state = scic_sds_phy_starting_await_sata_power_substate_enter,
+ .exit_state = scic_sds_phy_starting_await_sata_power_substate_exit
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN] = {
+ .enter_state = scic_sds_phy_starting_await_sata_phy_substate_enter,
+ .exit_state = scic_sds_phy_starting_await_sata_phy_substate_exit
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN] = {
+ .enter_state = scic_sds_phy_starting_await_sata_speed_substate_enter,
+ .exit_state = scic_sds_phy_starting_await_sata_speed_substate_exit
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF] = {
+ .enter_state = scic_sds_phy_starting_await_sig_fis_uf_substate_enter,
+ .exit_state = scic_sds_phy_starting_await_sig_fis_uf_substate_exit
+ },
+ [SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL] = {
+ .enter_state = scic_sds_phy_starting_final_substate_enter,
+ }
+};
+
+/*
+ * This method takes the struct scic_sds_phy from a stopped state and
+ * attempts to start it. - The phy state machine is transitioned to the
+ * SCI_BASE_PHY_STATE_STARTING. enum sci_status SCI_SUCCESS
+ */
+static enum sci_status
+scic_sds_phy_stopped_state_start_handler(struct scic_sds_phy *sci_phy)
+{
+ struct isci_host *ihost;
+ struct scic_sds_controller *scic;
+
+ scic = scic_sds_phy_get_controller(sci_phy),
+ ihost = scic_to_ihost(scic);
+
+ /* Create the SIGNATURE FIS Timeout timer for this phy */
+ sci_phy->sata_timeout_timer = isci_timer_create(ihost, sci_phy,
+ scic_sds_phy_sata_timeout);
+
+ if (sci_phy->sata_timeout_timer)
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STARTING);
+
+ return SCI_SUCCESS;
+}
+
+static enum sci_status
+scic_sds_phy_stopped_state_destroy_handler(struct scic_sds_phy *sci_phy)
+{
+ return SCI_SUCCESS;
+}
+
+static enum sci_status
+scic_sds_phy_ready_state_stop_handler(struct scic_sds_phy *sci_phy)
+{
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STOPPED);
+
+ return SCI_SUCCESS;
+}
+
+static enum sci_status
+scic_sds_phy_ready_state_reset_handler(struct scic_sds_phy *sci_phy)
+{
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_RESETTING);
+
+ return SCI_SUCCESS;
+}
+
+/**
+ * scic_sds_phy_ready_state_event_handler -
+ * @phy: This is the struct scic_sds_phy object which has received the event.
+ *
+ * This method request the struct scic_sds_phy handle the received event. The only
+ * event that we are interested in while in the ready state is the link failure
+ * event. - decoded event is a link failure - transition the struct scic_sds_phy back
+ * to the SCI_BASE_PHY_STATE_STARTING state. - any other event received will
+ * report a warning message enum sci_status SCI_SUCCESS if the event received is a
+ * link failure SCI_FAILURE_INVALID_STATE for any other event received.
+ */
+static enum sci_status scic_sds_phy_ready_state_event_handler(struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ enum sci_status result = SCI_FAILURE;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_LINK_FAILURE:
+ /* Link failure change state back to the starting state */
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STARTING);
+ result = SCI_SUCCESS;
+ break;
+
+ case SCU_EVENT_BROADCAST_CHANGE:
+ /* Broadcast change received. Notify the port. */
+ if (scic_sds_phy_get_port(sci_phy) != NULL)
+ scic_sds_port_broadcast_change_received(sci_phy->owning_port, sci_phy);
+ else
+ sci_phy->bcn_received_while_port_unassigned = true;
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%sP SCIC PHY 0x%p ready state machine received "
+ "unexpected event_code %x\n",
+ __func__, sci_phy, event_code);
+
+ result = SCI_FAILURE_INVALID_STATE;
+ break;
+ }
+
+ return result;
+}
+
+static enum sci_status scic_sds_phy_resetting_state_event_handler(struct scic_sds_phy *sci_phy,
+ u32 event_code)
+{
+ enum sci_status result = SCI_FAILURE;
+
+ switch (scu_get_event_code(event_code)) {
+ case SCU_EVENT_HARD_RESET_TRANSMITTED:
+ /* Link failure change state back to the starting state */
+ sci_base_state_machine_change_state(&sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STARTING);
+ result = SCI_SUCCESS;
+ break;
+
+ default:
+ dev_warn(sciphy_to_dev(sci_phy),
+ "%s: SCIC PHY 0x%p resetting state machine received "
+ "unexpected event_code %x\n",
+ __func__, sci_phy, event_code);
+
+ result = SCI_FAILURE_INVALID_STATE;
+ break;
+ }
+
+ return result;
+}
+
+/* --------------------------------------------------------------------------- */
+
+static const struct scic_sds_phy_state_handler scic_sds_phy_state_handler_table[] = {
+ [SCI_BASE_PHY_STATE_INITIAL] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_default_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_default_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCI_BASE_PHY_STATE_STOPPED] = {
+ .start_handler = scic_sds_phy_stopped_state_start_handler,
+ .stop_handler = scic_sds_phy_default_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_stopped_state_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_default_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCI_BASE_PHY_STATE_STARTING] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_default_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_default_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCI_BASE_PHY_STATE_READY] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_ready_state_stop_handler,
+ .reset_handler = scic_sds_phy_ready_state_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_ready_state_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCI_BASE_PHY_STATE_RESETTING] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_default_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_resetting_state_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ },
+ [SCI_BASE_PHY_STATE_FINAL] = {
+ .start_handler = scic_sds_phy_default_start_handler,
+ .stop_handler = scic_sds_phy_default_stop_handler,
+ .reset_handler = scic_sds_phy_default_reset_handler,
+ .destruct_handler = scic_sds_phy_default_destroy_handler,
+ .frame_handler = scic_sds_phy_default_frame_handler,
+ .event_handler = scic_sds_phy_default_event_handler,
+ .consume_power_handler = scic_sds_phy_default_consume_power_handler
+ }
+};
+
+/*
+ * ****************************************************************************
+ * * PHY STATE PRIVATE METHODS
+ * **************************************************************************** */
+
+/**
+ *
+ * @sci_phy: This is the struct scic_sds_phy object to stop.
+ *
+ * This method will stop the struct scic_sds_phy object. This does not reset the
+ * protocol engine it just suspends it and places it in a state where it will
+ * not cause the end device to power up. none
+ */
+static void scu_link_layer_stop_protocol_engine(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 scu_sas_pcfg_value;
+ u32 enable_spinup_value;
+
+ /* Suspend the protocol engine and place it in a sata spinup hold state */
+ scu_sas_pcfg_value =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ scu_sas_pcfg_value |=
+ (SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
+ SCU_SAS_PCFG_GEN_BIT(SUSPEND_PROTOCOL_ENGINE) |
+ SCU_SAS_PCFG_GEN_BIT(SATA_SPINUP_HOLD));
+ writel(scu_sas_pcfg_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ /* Disable the notify enable spinup primitives */
+ enable_spinup_value = readl(&sci_phy->link_layer_registers->notify_enable_spinup_control);
+ enable_spinup_value &= ~SCU_ENSPINUP_GEN_BIT(ENABLE);
+ writel(enable_spinup_value, &sci_phy->link_layer_registers->notify_enable_spinup_control);
+}
+
+/**
+ *
+ *
+ * This method will start the OOB/SN state machine for this struct scic_sds_phy object.
+ */
+static void scu_link_layer_start_oob(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 scu_sas_pcfg_value;
+
+ scu_sas_pcfg_value =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ scu_sas_pcfg_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
+ scu_sas_pcfg_value &=
+ ~(SCU_SAS_PCFG_GEN_BIT(OOB_RESET) |
+ SCU_SAS_PCFG_GEN_BIT(HARD_RESET));
+ writel(scu_sas_pcfg_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+}
+
+/**
+ *
+ *
+ * This method will transmit a hard reset request on the specified phy. The SCU
+ * hardware requires that we reset the OOB state machine and set the hard reset
+ * bit in the phy configuration register. We then must start OOB over with the
+ * hard reset bit set.
+ */
+static void scu_link_layer_tx_hard_reset(
+ struct scic_sds_phy *sci_phy)
+{
+ u32 phy_configuration_value;
+
+ /*
+ * SAS Phys must wait for the HARD_RESET_TX event notification to transition
+ * to the starting state. */
+ phy_configuration_value =
+ readl(&sci_phy->link_layer_registers->phy_configuration);
+ phy_configuration_value |=
+ (SCU_SAS_PCFG_GEN_BIT(HARD_RESET) |
+ SCU_SAS_PCFG_GEN_BIT(OOB_RESET));
+ writel(phy_configuration_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+
+ /* Now take the OOB state machine out of reset */
+ phy_configuration_value |= SCU_SAS_PCFG_GEN_BIT(OOB_ENABLE);
+ phy_configuration_value &= ~SCU_SAS_PCFG_GEN_BIT(OOB_RESET);
+ writel(phy_configuration_value,
+ &sci_phy->link_layer_registers->phy_configuration);
+}
+
+/*
+ * ****************************************************************************
+ * * PHY BASE STATE METHODS
+ * **************************************************************************** */
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
+ * handlers for the phy object base state machine initial state. none
+ */
+static void scic_sds_phy_initial_state_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_INITIAL);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This function will perform the actions required by the struct scic_sds_phy on
+ * entering the SCI_BASE_PHY_STATE_INITIAL. - This function sets the state
+ * handlers for the phy object base state machine initial state. - The SCU
+ * hardware is requested to stop the protocol engine. none
+ */
+static void scic_sds_phy_stopped_state_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+ struct scic_sds_controller *scic = scic_sds_phy_get_controller(sci_phy);
+ struct isci_host *ihost = scic_to_ihost(scic);
+
+ /*
+ * @todo We need to get to the controller to place this PE in a
+ * reset state
+ */
+
+ scic_sds_phy_set_base_state_handlers(sci_phy,
+ SCI_BASE_PHY_STATE_STOPPED);
+
+ if (sci_phy->sata_timeout_timer != NULL) {
+ isci_del_timer(ihost, sci_phy->sata_timeout_timer);
+
+ sci_phy->sata_timeout_timer = NULL;
+ }
+
+ scu_link_layer_stop_protocol_engine(sci_phy);
+
+ if (sci_phy->state_machine.previous_state_id !=
+ SCI_BASE_PHY_STATE_INITIAL)
+ scic_sds_controller_link_down(
+ scic_sds_phy_get_controller(sci_phy),
+ scic_sds_phy_get_port(sci_phy),
+ sci_phy);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCI_BASE_PHY_STATE_STARTING. - This function sets the state
+ * handlers for the phy object base state machine starting state. - The SCU
+ * hardware is requested to start OOB/SN on this protocl engine. - The phy
+ * starting substate machine is started. - If the previous state was the ready
+ * state then the struct scic_sds_controller is informed that the phy has gone link
+ * down. none
+ */
+static void scic_sds_phy_starting_state_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_STARTING);
+
+ scu_link_layer_stop_protocol_engine(sci_phy);
+ scu_link_layer_start_oob(sci_phy);
+
+ /* We don't know what kind of phy we are going to be just yet */
+ sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
+ sci_phy->bcn_received_while_port_unassigned = false;
+
+ /* Change over to the starting substate machine to continue */
+ sci_base_state_machine_start(&sci_phy->starting_substate_machine);
+
+ if (sci_phy->state_machine.previous_state_id
+ == SCI_BASE_PHY_STATE_READY) {
+ scic_sds_controller_link_down(
+ scic_sds_phy_get_controller(sci_phy),
+ scic_sds_phy_get_port(sci_phy),
+ sci_phy
+ );
+ }
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCI_BASE_PHY_STATE_READY. - This function sets the state
+ * handlers for the phy object base state machine ready state. - The SCU
+ * hardware protocol engine is resumed. - The struct scic_sds_controller is informed
+ * that the phy object has gone link up. none
+ */
+static void scic_sds_phy_ready_state_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_READY);
+
+ scic_sds_controller_link_up(
+ scic_sds_phy_get_controller(sci_phy),
+ scic_sds_phy_get_port(sci_phy),
+ sci_phy
+ );
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on exiting
+ * the SCI_BASE_PHY_STATE_INITIAL. This function suspends the SCU hardware
+ * protocol engine represented by this struct scic_sds_phy object. none
+ */
+static void scic_sds_phy_ready_state_exit(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_suspend(sci_phy);
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCI_BASE_PHY_STATE_RESETTING. - This function sets the state
+ * handlers for the phy object base state machine resetting state. none
+ */
+static void scic_sds_phy_resetting_state_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_RESETTING);
+
+ /*
+ * The phy is being reset, therefore deactivate it from the port.
+ * In the resetting state we don't notify the user regarding
+ * link up and link down notifications. */
+ scic_sds_port_deactivate_phy(sci_phy->owning_port, sci_phy, false);
+
+ if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SAS) {
+ scu_link_layer_tx_hard_reset(sci_phy);
+ } else {
+ /*
+ * The SCU does not need to have a discrete reset state so
+ * just go back to the starting state.
+ */
+ sci_base_state_machine_change_state(
+ &sci_phy->state_machine,
+ SCI_BASE_PHY_STATE_STARTING);
+ }
+}
+
+/**
+ *
+ * @object: This is the object which is cast to a struct scic_sds_phy object.
+ *
+ * This method will perform the actions required by the struct scic_sds_phy on
+ * entering the SCI_BASE_PHY_STATE_FINAL. - This function sets the state
+ * handlers for the phy object base state machine final state. none
+ */
+static void scic_sds_phy_final_state_enter(void *object)
+{
+ struct scic_sds_phy *sci_phy = object;
+
+ scic_sds_phy_set_base_state_handlers(sci_phy, SCI_BASE_PHY_STATE_FINAL);
+
+ /* Nothing to do here */
+}
+
+/* --------------------------------------------------------------------------- */
+
+static const struct sci_base_state scic_sds_phy_state_table[] = {
+ [SCI_BASE_PHY_STATE_INITIAL] = {
+ .enter_state = scic_sds_phy_initial_state_enter,
+ },
+ [SCI_BASE_PHY_STATE_STOPPED] = {
+ .enter_state = scic_sds_phy_stopped_state_enter,
+ },
+ [SCI_BASE_PHY_STATE_STARTING] = {
+ .enter_state = scic_sds_phy_starting_state_enter,
+ },
+ [SCI_BASE_PHY_STATE_READY] = {
+ .enter_state = scic_sds_phy_ready_state_enter,
+ .exit_state = scic_sds_phy_ready_state_exit,
+ },
+ [SCI_BASE_PHY_STATE_RESETTING] = {
+ .enter_state = scic_sds_phy_resetting_state_enter,
+ },
+ [SCI_BASE_PHY_STATE_FINAL] = {
+ .enter_state = scic_sds_phy_final_state_enter,
+ },
+};
+
+void scic_sds_phy_construct(struct scic_sds_phy *sci_phy,
+ struct scic_sds_port *owning_port, u8 phy_index)
+{
+ sci_base_state_machine_construct(&sci_phy->state_machine,
+ sci_phy,
+ scic_sds_phy_state_table,
+ SCI_BASE_PHY_STATE_INITIAL);
+
+ sci_base_state_machine_start(&sci_phy->state_machine);
+
+ /* Copy the rest of the input data to our locals */
+ sci_phy->owning_port = owning_port;
+ sci_phy->phy_index = phy_index;
+ sci_phy->bcn_received_while_port_unassigned = false;
+ sci_phy->protocol = SCIC_SDS_PHY_PROTOCOL_UNKNOWN;
+ sci_phy->link_layer_registers = NULL;
+ sci_phy->max_negotiated_speed = SAS_LINK_RATE_UNKNOWN;
+ sci_phy->sata_timeout_timer = NULL;
+
+ /* Initialize the the substate machines */
+ sci_base_state_machine_construct(&sci_phy->starting_substate_machine,
+ sci_phy,
+ scic_sds_phy_starting_substates,
+ SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL);
+}
void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index)
{
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h
index 3a95adbb508c..093fd473366c 100644
--- a/drivers/scsi/isci/phy.h
+++ b/drivers/scsi/isci/phy.h
@@ -57,7 +57,105 @@
#include <scsi/sas.h>
#include <scsi/libsas.h>
-#include "scic_sds_phy.h"
+#include "state_machine.h"
+
+/* This is the timeout value for the SATA phy to wait for a SIGNATURE FIS
+ * before restarting the starting state machine. Technically, the old parallel
+ * ATA specification required up to 30 seconds for a device to issue its
+ * signature FIS as a result of a soft reset. Now we see that devices respond
+ * generally within 15 seconds, but we'll use 25 for now.
+ */
+#define SCIC_SDS_SIGNATURE_FIS_TIMEOUT 25000
+
+/* This is the timeout for the SATA OOB/SN because the hardware does not
+ * recognize a hot plug after OOB signal but before the SN signals. We need to
+ * make sure after a hotplug timeout if we have not received the speed event
+ * notification from the hardware that we restart the hardware OOB state
+ * machine.
+ */
+#define SCIC_SDS_SATA_LINK_TRAINING_TIMEOUT 250
+
+enum scic_sds_phy_protocol {
+ SCIC_SDS_PHY_PROTOCOL_UNKNOWN,
+ SCIC_SDS_PHY_PROTOCOL_SAS,
+ SCIC_SDS_PHY_PROTOCOL_SATA,
+ SCIC_SDS_MAX_PHY_PROTOCOLS
+};
+
+/**
+ * struct scic_sds_phy - This structure contains or references all of the data
+ * necessary to represent the core phy object and SCU harware protocol
+ * engine.
+ *
+ *
+ */
+struct scic_sds_phy {
+ /**
+ * This field contains the information for the base phy state machine.
+ */
+ struct sci_base_state_machine state_machine;
+
+ /**
+ * This field specifies the port object that owns/contains this phy.
+ */
+ struct scic_sds_port *owning_port;
+
+ /**
+ * This field indicates whether the phy supports 1.5 Gb/s, 3.0 Gb/s,
+ * or 6.0 Gb/s operation.
+ */
+ enum sas_linkrate max_negotiated_speed;
+
+ /**
+ * This member specifies the protocol being utilized on this phy. This
+ * field contains a legitamite value once the PHY has link trained with
+ * a remote phy.
+ */
+ enum scic_sds_phy_protocol protocol;
+
+ /**
+ * This field specifies the index with which this phy is associated (0-3).
+ */
+ u8 phy_index;
+
+ /**
+ * This member indicates if this particular PHY has received a BCN while
+ * it had no port assignement. This BCN will be reported once the phy is
+ * assigned to a port.
+ */
+ bool bcn_received_while_port_unassigned;
+
+ /**
+ * This field indicates if this PHY is currently in the process of
+ * link training (i.e. it has started OOB, but has yet to perform
+ * IAF exchange/Signature FIS reception).
+ */
+ bool is_in_link_training;
+
+ /**
+ * This field contains a reference to the timer utilized in detecting
+ * when a signature FIS timeout has occurred. The signature FIS is the
+ * first FIS sent by an attached SATA device after OOB/SN.
+ */
+ void *sata_timeout_timer;
+
+ const struct scic_sds_phy_state_handler *state_handlers;
+
+ struct sci_base_state_machine starting_substate_machine;
+
+ /**
+ * This field is the pointer to the transport layer register for the SCU
+ * hardware.
+ */
+ struct scu_transport_layer_registers __iomem *transport_layer_registers;
+
+ /**
+ * This field points to the link layer register set within the SCU.
+ */
+ struct scu_link_layer_registers __iomem *link_layer_registers;
+
+};
+
struct isci_phy {
struct scic_sds_phy sci;
@@ -85,6 +183,480 @@ static inline struct isci_phy *sci_phy_to_iphy(struct scic_sds_phy *sci_phy)
return iphy;
}
+struct scic_phy_cap {
+ union {
+ struct {
+ /*
+ * The SAS specification indicates the start bit shall
+ * always be set to
+ * 1. This implementation will have the start bit set
+ * to 0 if the PHY CAPABILITIES were either not
+ * received or speed negotiation failed.
+ */
+ u8 start:1;
+ u8 tx_ssc_type:1;
+ u8 res1:2;
+ u8 req_logical_linkrate:4;
+
+ u32 gen1_no_ssc:1;
+ u32 gen1_ssc:1;
+ u32 gen2_no_ssc:1;
+ u32 gen2_ssc:1;
+ u32 gen3_no_ssc:1;
+ u32 gen3_ssc:1;
+ u32 res2:17;
+ u32 parity:1;
+ };
+ u32 all;
+ };
+} __packed;
+
+/* this data structure reflects the link layer transmit identification reg */
+struct scic_phy_proto {
+ union {
+ struct {
+ u16 _r_a:1;
+ u16 smp_iport:1;
+ u16 stp_iport:1;
+ u16 ssp_iport:1;
+ u16 _r_b:4;
+ u16 _r_c:1;
+ u16 smp_tport:1;
+ u16 stp_tport:1;
+ u16 ssp_tport:1;
+ u16 _r_d:4;
+ };
+ u16 all;
+ };
+} __packed;
+
+
+/**
+ * struct scic_phy_properties - This structure defines the properties common to
+ * all phys that can be retrieved.
+ *
+ *
+ */
+struct scic_phy_properties {
+ /**
+ * This field specifies the port that currently contains the
+ * supplied phy. This field may be set to NULL
+ * if the phy is not currently contained in a port.
+ */
+ struct scic_sds_port *owning_port;
+
+ /**
+ * This field specifies the link rate at which the phy is
+ * currently operating.
+ */
+ enum sas_linkrate negotiated_link_rate;
+
+ /**
+ * This field specifies the index of the phy in relation to other
+ * phys within the controller. This index is zero relative.
+ */
+ u8 index;
+};
+
+/**
+ * struct scic_sas_phy_properties - This structure defines the properties,
+ * specific to a SAS phy, that can be retrieved.
+ *
+ *
+ */
+struct scic_sas_phy_properties {
+ /**
+ * This field delineates the Identify Address Frame received
+ * from the remote end point.
+ */
+ struct sas_identify_frame rcvd_iaf;
+
+ /**
+ * This field delineates the Phy capabilities structure received
+ * from the remote end point.
+ */
+ struct scic_phy_cap rcvd_cap;
+
+};
+
+/**
+ * struct scic_sata_phy_properties - This structure defines the properties,
+ * specific to a SATA phy, that can be retrieved.
+ *
+ *
+ */
+struct scic_sata_phy_properties {
+ /**
+ * This field delineates the signature FIS received from the
+ * attached target.
+ */
+ struct dev_to_host_fis signature_fis;
+
+ /**
+ * This field specifies to the user if a port selector is connected
+ * on the specified phy.
+ */
+ bool is_port_selector_present;
+
+};
+
+/**
+ * enum scic_phy_counter_id - This enumeration depicts the various pieces of
+ * optional information that can be retrieved for a specific phy.
+ *
+ *
+ */
+enum scic_phy_counter_id {
+ /**
+ * This PHY information field tracks the number of frames received.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_FRAME,
+
+ /**
+ * This PHY information field tracks the number of frames transmitted.
+ */
+ SCIC_PHY_COUNTER_TRANSMITTED_FRAME,
+
+ /**
+ * This PHY information field tracks the number of DWORDs received.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_FRAME_WORD,
+
+ /**
+ * This PHY information field tracks the number of DWORDs transmitted.
+ */
+ SCIC_PHY_COUNTER_TRANSMITTED_FRAME_DWORD,
+
+ /**
+ * This PHY information field tracks the number of times DWORD
+ * synchronization was lost.
+ */
+ SCIC_PHY_COUNTER_LOSS_OF_SYNC_ERROR,
+
+ /**
+ * This PHY information field tracks the number of received DWORDs with
+ * running disparity errors.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_DISPARITY_ERROR,
+
+ /**
+ * This PHY information field tracks the number of received frames with a
+ * CRC error (not including short or truncated frames).
+ */
+ SCIC_PHY_COUNTER_RECEIVED_FRAME_CRC_ERROR,
+
+ /**
+ * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT)
+ * primitives received.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_DONE_ACK_NAK_TIMEOUT,
+
+ /**
+ * This PHY information field tracks the number of DONE (ACK/NAK TIMEOUT)
+ * primitives transmitted.
+ */
+ SCIC_PHY_COUNTER_TRANSMITTED_DONE_ACK_NAK_TIMEOUT,
+
+ /**
+ * This PHY information field tracks the number of times the inactivity
+ * timer for connections on the phy has been utilized.
+ */
+ SCIC_PHY_COUNTER_INACTIVITY_TIMER_EXPIRED,
+
+ /**
+ * This PHY information field tracks the number of DONE (CREDIT TIMEOUT)
+ * primitives received.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_DONE_CREDIT_TIMEOUT,
+
+ /**
+ * This PHY information field tracks the number of DONE (CREDIT TIMEOUT)
+ * primitives transmitted.
+ */
+ SCIC_PHY_COUNTER_TRANSMITTED_DONE_CREDIT_TIMEOUT,
+
+ /**
+ * This PHY information field tracks the number of CREDIT BLOCKED
+ * primitives received.
+ * @note Depending on remote device implementation, credit blocks
+ * may occur regularly.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_CREDIT_BLOCKED,
+
+ /**
+ * This PHY information field contains the number of short frames
+ * received. A short frame is simply a frame smaller then what is
+ * allowed by either the SAS or SATA specification.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_SHORT_FRAME,
+
+ /**
+ * This PHY information field contains the number of frames received after
+ * credit has been exhausted.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_FRAME_WITHOUT_CREDIT,
+
+ /**
+ * This PHY information field contains the number of frames received after
+ * a DONE has been received.
+ */
+ SCIC_PHY_COUNTER_RECEIVED_FRAME_AFTER_DONE,
+
+ /**
+ * This PHY information field contains the number of times the phy
+ * failed to achieve DWORD synchronization during speed negotiation.
+ */
+ SCIC_PHY_COUNTER_SN_DWORD_SYNC_ERROR
+};
+
+enum scic_sds_phy_states {
+ /**
+ * Simply the initial state for the base domain state machine.
+ */
+ SCI_BASE_PHY_STATE_INITIAL,
+
+ /**
+ * This state indicates that the phy has successfully been stopped.
+ * In this state no new IO operations are permitted on this phy.
+ * This state is entered from the INITIAL state.
+ * This state is entered from the STARTING state.
+ * This state is entered from the READY state.
+ * This state is entered from the RESETTING state.
+ */
+ SCI_BASE_PHY_STATE_STOPPED,
+
+ /**
+ * This state indicates that the phy is in the process of becomming
+ * ready. In this state no new IO operations are permitted on this phy.
+ * This state is entered from the STOPPED state.
+ * This state is entered from the READY state.
+ * This state is entered from the RESETTING state.
+ */
+ SCI_BASE_PHY_STATE_STARTING,
+
+ /**
+ * This state indicates the the phy is now ready. Thus, the user
+ * is able to perform IO operations utilizing this phy as long as it
+ * is currently part of a valid port.
+ * This state is entered from the STARTING state.
+ */
+ SCI_BASE_PHY_STATE_READY,
+
+ /**
+ * This state indicates that the phy is in the process of being reset.
+ * In this state no new IO operations are permitted on this phy.
+ * This state is entered from the READY state.
+ */
+ SCI_BASE_PHY_STATE_RESETTING,
+
+ /**
+ * Simply the final state for the base phy state machine.
+ */
+ SCI_BASE_PHY_STATE_FINAL,
+};
+
+
+/**
+ * enum scic_sds_phy_starting_substates -
+ *
+ *
+ */
+enum scic_sds_phy_starting_substates {
+ /**
+ * Initial state
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_INITIAL,
+
+ /**
+ * Wait state for the hardware OSSP event type notification
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_OSSP_EN,
+
+ /**
+ * Wait state for the PHY speed notification
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_SPEED_EN,
+
+ /**
+ * Wait state for the IAF Unsolicited frame notification
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_IAF_UF,
+
+ /**
+ * Wait state for the request to consume power
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SAS_POWER,
+
+ /**
+ * Wait state for request to consume power
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_POWER,
+
+ /**
+ * Wait state for the SATA PHY notification
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_PHY_EN,
+
+ /**
+ * Wait for the SATA PHY speed notification
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SATA_SPEED_EN,
+
+ /**
+ * Wait state for the SIGNATURE FIS unsolicited frame notification
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_AWAIT_SIG_FIS_UF,
+
+ /**
+ * Exit state for this state machine
+ */
+ SCIC_SDS_PHY_STARTING_SUBSTATE_FINAL,
+};
+
+
+
+typedef enum sci_status (*scic_sds_phy_handler_t)(struct scic_sds_phy *);
+typedef enum sci_status (*scic_sds_phy_event_handler_t)(struct scic_sds_phy *, u32);
+typedef enum sci_status (*scic_sds_phy_frame_handler_t)(struct scic_sds_phy *, u32);
+typedef enum sci_status (*scic_sds_phy_power_handler_t)(struct scic_sds_phy *);
+
+struct scic_sds_phy_state_handler {
+ /**
+ * The start_handler specifies the method invoked when there is an
+ * attempt to start a phy.
+ */
+ scic_sds_phy_handler_t start_handler;
+
+ /**
+ * The stop_handler specifies the method invoked when there is an
+ * attempt to stop a phy.
+ */
+ scic_sds_phy_handler_t stop_handler;
+
+ /**
+ * The reset_handler specifies the method invoked when there is an
+ * attempt to reset a phy.
+ */
+ scic_sds_phy_handler_t reset_handler;
+
+ /**
+ * The destruct_handler specifies the method invoked when attempting to
+ * destruct a phy.
+ */
+ scic_sds_phy_handler_t destruct_handler;
+
+ /**
+ * The state handler for unsolicited frames received from the SCU hardware.
+ */
+ scic_sds_phy_frame_handler_t frame_handler;
+
+ /**
+ * The state handler for events received from the SCU hardware.
+ */
+ scic_sds_phy_event_handler_t event_handler;
+
+ /**
+ * The state handler for staggered spinup.
+ */
+ scic_sds_phy_power_handler_t consume_power_handler;
+
+};
+
+/**
+ * scic_sds_phy_get_index() -
+ *
+ * This macro returns the phy index for the specified phy
+ */
+#define scic_sds_phy_get_index(phy) \
+ ((phy)->phy_index)
+
+/**
+ * scic_sds_phy_get_controller() - This macro returns the controller for this
+ * phy
+ *
+ *
+ */
+#define scic_sds_phy_get_controller(phy) \
+ (scic_sds_port_get_controller((phy)->owning_port))
+
+/**
+ * scic_sds_phy_set_state_handlers() - This macro sets the state handlers for
+ * this phy object
+ *
+ *
+ */
+#define scic_sds_phy_set_state_handlers(phy, handlers) \
+ ((phy)->state_handlers = (handlers))
+
+/**
+ * scic_sds_phy_set_base_state_handlers() -
+ *
+ * This macro set the base state handlers for the phy object.
+ */
+#define scic_sds_phy_set_base_state_handlers(phy, state_id) \
+ scic_sds_phy_set_state_handlers(\
+ (phy), \
+ &scic_sds_phy_state_handler_table[(state_id)] \
+ )
+
+void scic_sds_phy_construct(
+ struct scic_sds_phy *this_phy,
+ struct scic_sds_port *owning_port,
+ u8 phy_index);
+
+struct scic_sds_port *scic_sds_phy_get_port(
+ struct scic_sds_phy *this_phy);
+
+void scic_sds_phy_set_port(
+ struct scic_sds_phy *this_phy,
+ struct scic_sds_port *owning_port);
+
+enum sci_status scic_sds_phy_initialize(
+ struct scic_sds_phy *this_phy,
+ struct scu_transport_layer_registers __iomem *transport_layer_registers,
+ struct scu_link_layer_registers __iomem *link_layer_registers);
+
+enum sci_status scic_sds_phy_start(
+ struct scic_sds_phy *this_phy);
+
+enum sci_status scic_sds_phy_stop(
+ struct scic_sds_phy *this_phy);
+
+enum sci_status scic_sds_phy_reset(
+ struct scic_sds_phy *this_phy);
+
+void scic_sds_phy_resume(
+ struct scic_sds_phy *this_phy);
+
+void scic_sds_phy_setup_transport(
+ struct scic_sds_phy *this_phy,
+ u32 device_id);
+
+enum sci_status scic_sds_phy_event_handler(
+ struct scic_sds_phy *this_phy,
+ u32 event_code);
+
+enum sci_status scic_sds_phy_frame_handler(
+ struct scic_sds_phy *this_phy,
+ u32 frame_index);
+
+enum sci_status scic_sds_phy_consume_power_handler(
+ struct scic_sds_phy *this_phy);
+
+void scic_sds_phy_get_sas_address(
+ struct scic_sds_phy *this_phy,
+ struct sci_sas_address *sas_address);
+
+void scic_sds_phy_get_attached_sas_address(
+ struct scic_sds_phy *this_phy,
+ struct sci_sas_address *sas_address);
+
+struct scic_phy_proto;
+void scic_sds_phy_get_protocols(
+ struct scic_sds_phy *sci_phy,
+ struct scic_phy_proto *protocols);
+enum sas_linkrate sci_phy_linkrate(struct scic_sds_phy *sci_phy);
+
struct isci_host;
void isci_phy_init(struct isci_phy *iphy, struct isci_host *ihost, int index);
int isci_phy_control(struct asd_sas_phy *phy, enum phy_func func, void *buf);
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index d4bf6d2d8c9b..321935d9560b 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -55,8 +55,6 @@
#include <linux/workqueue.h>
#include "isci.h"
-#include "scic_phy.h"
-#include "scic_sds_phy.h"
#include "scic_port.h"
#include "port.h"
#include "request.h"
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 23390102514f..2baa215cb275 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -57,9 +57,7 @@
#include "port.h"
#include "remote_device.h"
#include "request.h"
-#include "scic_phy.h"
#include "scic_port.h"
-#include "scic_sds_phy.h"
#include "scic_sds_port.h"
#include "remote_node_context.h"
#include "scu_event_codes.h"