diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-02-23 03:09:01 -0500 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 06:55:28 -0400 |
commit | 3c06c2839dac6db56a1e6bd11924db38eddfb2ed (patch) | |
tree | c3c1c5d1e56657bb2cef3fd21155da4e99217e90 /drivers/scsi | |
parent | d9def184b39b966b7496dfbfad126808d3cd701b (diff) |
isci: clean up remaining silicon revision ifdefs in phy init
Use the dynamic revision detection code in
scic_sds_phy_link_layer_initialization() and apply some coding style
fixups (long deref chains). The compile time max link rate setting is
removed in favor of honoring the user-parameter max.
Reported-by: Krzysztof Wierzbicki <Krzysztof.Wierzbicki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/isci/core/scic_config_parameters.h | 4 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_controller.c | 15 | ||||
-rw-r--r-- | drivers/scsi/isci/core/scic_sds_phy.c | 173 | ||||
-rw-r--r-- | drivers/scsi/isci/sci_environment.h | 14 |
4 files changed, 85 insertions, 121 deletions
diff --git a/drivers/scsi/isci/core/scic_config_parameters.h b/drivers/scsi/isci/core/scic_config_parameters.h index 8bd85605130c..485fefc08883 100644 --- a/drivers/scsi/isci/core/scic_config_parameters.h +++ b/drivers/scsi/isci/core/scic_config_parameters.h | |||
@@ -114,7 +114,7 @@ struct scic_sds_controller; | |||
114 | * | 114 | * |
115 | */ | 115 | */ |
116 | struct scic_sds_user_parameters { | 116 | struct scic_sds_user_parameters { |
117 | struct { | 117 | struct sci_phy_user_params { |
118 | /** | 118 | /** |
119 | * This field specifies the NOTIFY (ENABLE SPIN UP) primitive | 119 | * This field specifies the NOTIFY (ENABLE SPIN UP) primitive |
120 | * insertion frequency for this phy index. | 120 | * insertion frequency for this phy index. |
@@ -250,7 +250,7 @@ struct scic_sds_oem_parameters { | |||
250 | 250 | ||
251 | } ports[SCI_MAX_PORTS]; | 251 | } ports[SCI_MAX_PORTS]; |
252 | 252 | ||
253 | struct { | 253 | struct sci_phy_oem_params { |
254 | /** | 254 | /** |
255 | * This field specifies the SAS address to be transmitted on | 255 | * This field specifies the SAS address to be transmitted on |
256 | * for this phy index. | 256 | * for this phy index. |
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c index d9fca9976889..e8d09fd935ec 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.c +++ b/drivers/scsi/isci/core/scic_sds_controller.c | |||
@@ -584,21 +584,6 @@ void scic_sds_controller_enable_port_task_scheduler( | |||
584 | */ | 584 | */ |
585 | #define AFE_REGISTER_WRITE_DELAY 10 | 585 | #define AFE_REGISTER_WRITE_DELAY 10 |
586 | 586 | ||
587 | static bool is_a0(void) | ||
588 | { | ||
589 | return isci_si_rev == ISCI_SI_REVA0; | ||
590 | } | ||
591 | |||
592 | static bool is_a2(void) | ||
593 | { | ||
594 | return isci_si_rev == ISCI_SI_REVA2; | ||
595 | } | ||
596 | |||
597 | static bool is_b0(void) | ||
598 | { | ||
599 | return isci_si_rev > ISCI_SI_REVA2; | ||
600 | } | ||
601 | |||
602 | /* Initialize the AFE for this phy index. We need to read the AFE setup from | 587 | /* Initialize the AFE for this phy index. We need to read the AFE setup from |
603 | * the OEM parameters none | 588 | * the OEM parameters none |
604 | */ | 589 | */ |
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c index ecd7cc698ae6..e8d5be73cd0b 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.c +++ b/drivers/scsi/isci/core/scic_sds_phy.c | |||
@@ -111,62 +111,55 @@ static enum sci_status scic_sds_phy_transport_layer_initialization( | |||
111 | 111 | ||
112 | /** | 112 | /** |
113 | * This method will initialize the phy link layer registers | 113 | * This method will initialize the phy link layer registers |
114 | * @this_phy: | 114 | * @sci_phy: |
115 | * @link_layer_registers: | 115 | * @link_layer_registers: |
116 | * | 116 | * |
117 | * enum sci_status | 117 | * enum sci_status |
118 | */ | 118 | */ |
119 | static enum sci_status scic_sds_phy_link_layer_initialization( | 119 | static enum sci_status |
120 | struct scic_sds_phy *this_phy, | 120 | scic_sds_phy_link_layer_initialization(struct scic_sds_phy *sci_phy, |
121 | struct scu_link_layer_registers __iomem *link_layer_registers) | 121 | struct scu_link_layer_registers __iomem *link_layer_registers) |
122 | { | 122 | { |
123 | struct scic_sds_controller *scic = sci_phy->owning_port->owning_controller; | ||
124 | int phy_idx = sci_phy->phy_index; | ||
125 | struct sci_phy_user_params *phy_user = &scic->user_parameters.sds1.phys[phy_idx]; | ||
126 | struct sci_phy_oem_params *phy_oem = &scic->oem_parameters.sds1.phys[phy_idx]; | ||
123 | u32 phy_configuration; | 127 | u32 phy_configuration; |
124 | struct sas_capabilities phy_capabilities; | 128 | struct sas_capabilities phy_capabilities; |
125 | u32 parity_check = 0; | 129 | u32 parity_check = 0; |
126 | u32 parity_count = 0; | 130 | u32 parity_count = 0; |
127 | u32 link_layer_control; | 131 | u32 llctl, link_rate; |
128 | u32 clksm_value = 0; | 132 | u32 clksm_value = 0; |
129 | 133 | ||
130 | this_phy->link_layer_registers = link_layer_registers; | 134 | sci_phy->link_layer_registers = link_layer_registers; |
131 | 135 | ||
132 | /* Set our IDENTIFY frame data */ | 136 | /* Set our IDENTIFY frame data */ |
133 | #define SCI_END_DEVICE 0x01 | 137 | #define SCI_END_DEVICE 0x01 |
134 | 138 | ||
135 | SCU_SAS_TIID_WRITE( | 139 | SCU_SAS_TIID_WRITE(sci_phy, (SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) | |
136 | this_phy, | 140 | SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) | |
137 | (SCU_SAS_TIID_GEN_BIT(SMP_INITIATOR) | 141 | SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) | |
138 | | SCU_SAS_TIID_GEN_BIT(SSP_INITIATOR) | 142 | SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) | |
139 | | SCU_SAS_TIID_GEN_BIT(STP_INITIATOR) | 143 | SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE))); |
140 | | SCU_SAS_TIID_GEN_BIT(DA_SATA_HOST) | ||
141 | | SCU_SAS_TIID_GEN_VAL(DEVICE_TYPE, SCI_END_DEVICE)) | ||
142 | ); | ||
143 | 144 | ||
144 | /* Write the device SAS Address */ | 145 | /* Write the device SAS Address */ |
145 | SCU_SAS_TIDNH_WRITE(this_phy, 0xFEDCBA98); | 146 | SCU_SAS_TIDNH_WRITE(sci_phy, 0xFEDCBA98); |
146 | SCU_SAS_TIDNL_WRITE(this_phy, this_phy->phy_index); | 147 | SCU_SAS_TIDNL_WRITE(sci_phy, phy_idx); |
147 | 148 | ||
148 | /* Write the source SAS Address */ | 149 | /* Write the source SAS Address */ |
149 | SCU_SAS_TISSAH_WRITE( | 150 | SCU_SAS_TISSAH_WRITE(sci_phy, phy_oem->sas_address.high); |
150 | this_phy, | 151 | SCU_SAS_TISSAL_WRITE(sci_phy, phy_oem->sas_address.low); |
151 | this_phy->owning_port->owning_controller->oem_parameters.sds1.phys[ | ||
152 | this_phy->phy_index].sas_address.high | ||
153 | ); | ||
154 | SCU_SAS_TISSAL_WRITE( | ||
155 | this_phy, | ||
156 | this_phy->owning_port->owning_controller->oem_parameters.sds1.phys[ | ||
157 | this_phy->phy_index].sas_address.low | ||
158 | ); | ||
159 | 152 | ||
160 | /* Clear and Set the PHY Identifier */ | 153 | /* Clear and Set the PHY Identifier */ |
161 | SCU_SAS_TIPID_WRITE(this_phy, 0x00000000); | 154 | SCU_SAS_TIPID_WRITE(sci_phy, 0x00000000); |
162 | SCU_SAS_TIPID_WRITE(this_phy, SCU_SAS_TIPID_GEN_VALUE(ID, this_phy->phy_index)); | 155 | SCU_SAS_TIPID_WRITE(sci_phy, SCU_SAS_TIPID_GEN_VALUE(ID, phy_idx)); |
163 | 156 | ||
164 | /* Change the initial state of the phy configuration register */ | 157 | /* Change the initial state of the phy configuration register */ |
165 | phy_configuration = SCU_SAS_PCFG_READ(this_phy); | 158 | phy_configuration = SCU_SAS_PCFG_READ(sci_phy); |
166 | 159 | ||
167 | /* Hold OOB state machine in reset */ | 160 | /* Hold OOB state machine in reset */ |
168 | phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); | 161 | phy_configuration |= SCU_SAS_PCFG_GEN_BIT(OOB_RESET); |
169 | SCU_SAS_PCFG_WRITE(this_phy, phy_configuration); | 162 | SCU_SAS_PCFG_WRITE(sci_phy, phy_configuration); |
170 | 163 | ||
171 | /* Configure the SNW capabilities */ | 164 | /* Configure the SNW capabilities */ |
172 | phy_capabilities.u.all = 0; | 165 | phy_capabilities.u.all = 0; |
@@ -174,8 +167,7 @@ static enum sci_status scic_sds_phy_link_layer_initialization( | |||
174 | phy_capabilities.u.bits.gen3_without_ssc_supported = 1; | 167 | phy_capabilities.u.bits.gen3_without_ssc_supported = 1; |
175 | phy_capabilities.u.bits.gen2_without_ssc_supported = 1; | 168 | phy_capabilities.u.bits.gen2_without_ssc_supported = 1; |
176 | phy_capabilities.u.bits.gen1_without_ssc_supported = 1; | 169 | phy_capabilities.u.bits.gen1_without_ssc_supported = 1; |
177 | if (this_phy->owning_port->owning_controller->oem_parameters.sds1. | 170 | if (scic->oem_parameters.sds1.controller.do_enable_ssc == true) { |
178 | controller.do_enable_ssc == true) { | ||
179 | phy_capabilities.u.bits.gen3_with_ssc_supported = 1; | 171 | phy_capabilities.u.bits.gen3_with_ssc_supported = 1; |
180 | phy_capabilities.u.bits.gen2_with_ssc_supported = 1; | 172 | phy_capabilities.u.bits.gen2_with_ssc_supported = 1; |
181 | phy_capabilities.u.bits.gen1_with_ssc_supported = 1; | 173 | phy_capabilities.u.bits.gen1_with_ssc_supported = 1; |
@@ -197,93 +189,66 @@ static enum sci_status scic_sds_phy_link_layer_initialization( | |||
197 | if ((parity_count % 2) != 0) | 189 | if ((parity_count % 2) != 0) |
198 | phy_capabilities.u.bits.parity = 1; | 190 | phy_capabilities.u.bits.parity = 1; |
199 | 191 | ||
200 | SCU_SAS_PHYCAP_WRITE(this_phy, phy_capabilities.u.all); | 192 | SCU_SAS_PHYCAP_WRITE(sci_phy, phy_capabilities.u.all); |
201 | 193 | ||
202 | /* Set the enable spinup period but disable the ability to send notify enable spinup */ | 194 | /* Set the enable spinup period but disable the ability to send |
203 | SCU_SAS_ENSPINUP_WRITE(this_phy, SCU_ENSPINUP_GEN_VAL(COUNT, | 195 | * notify enable spinup |
204 | this_phy->owning_port->owning_controller->user_parameters.sds1. | 196 | */ |
205 | phys[this_phy->phy_index].notify_enable_spin_up_insertion_frequency)); | 197 | SCU_SAS_ENSPINUP_WRITE(sci_phy, SCU_ENSPINUP_GEN_VAL(COUNT, |
198 | phy_user->notify_enable_spin_up_insertion_frequency)); | ||
206 | 199 | ||
207 | /* Write the ALIGN Insertion Ferequency for connected phy and inpendent of connected state */ | 200 | /* Write the ALIGN Insertion Ferequency for connected phy and |
201 | * inpendent of connected state | ||
202 | */ | ||
208 | clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED, | 203 | clksm_value = SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(CONNECTED, |
209 | this_phy->owning_port->owning_controller->user_parameters.sds1. | 204 | phy_user->in_connection_align_insertion_frequency); |
210 | phys[this_phy->phy_index].in_connection_align_insertion_frequency); | ||
211 | 205 | ||
212 | clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL, | 206 | clksm_value |= SCU_ALIGN_INSERTION_FREQUENCY_GEN_VAL(GENERAL, |
213 | this_phy->owning_port->owning_controller->user_parameters.sds1. | 207 | phy_user->align_insertion_frequency); |
214 | phys[this_phy->phy_index].align_insertion_frequency); | ||
215 | |||
216 | SCU_SAS_CLKSM_WRITE(this_phy, clksm_value); | ||
217 | |||
218 | #if defined(CONFIG_PBG_HBA_A0) || defined(CONFIG_PBG_HBA_A2) || defined(CONFIG_PBG_HBA_BETA) | ||
219 | /* / @todo Provide a way to write this register correctly */ | ||
220 | scu_link_layer_register_write(this_phy, afe_lookup_table_control, 0x02108421); | ||
221 | #else | ||
222 | /* / @todo Provide a way to write this register correctly */ | ||
223 | scu_link_layer_register_write(this_phy, afe_lookup_table_control, 0x0e739ce7); | ||
224 | #endif | ||
225 | |||
226 | link_layer_control = SCU_SAS_LLCTL_GEN_VAL( | ||
227 | NO_OUTBOUND_TASK_TIMEOUT, | ||
228 | (u8)this_phy->owning_port->owning_controller-> | ||
229 | user_parameters.sds1.no_outbound_task_timeout | ||
230 | ); | ||
231 | 208 | ||
232 | /* #define COMPILED_MAX_LINK_RATE SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1 */ | 209 | SCU_SAS_CLKSM_WRITE(sci_phy, clksm_value); |
233 | /* #define COMPILED_MAX_LINK_RATE SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2 */ | ||
234 | #define COMPILED_MAX_LINK_RATE SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3 | ||
235 | 210 | ||
236 | if (this_phy->owning_port->owning_controller->user_parameters.sds1. | 211 | /* @todo Provide a way to write this register correctly */ |
237 | phys[this_phy->phy_index].max_speed_generation == SCIC_SDS_PARM_GEN3_SPEED) { | 212 | scu_link_layer_register_write(sci_phy, afe_lookup_table_control, 0x02108421); |
238 | link_layer_control |= SCU_SAS_LLCTL_GEN_VAL( | ||
239 | MAX_LINK_RATE, COMPILED_MAX_LINK_RATE | ||
240 | ); | ||
241 | } else if (this_phy->owning_port->owning_controller->user_parameters.sds1. | ||
242 | phys[this_phy->phy_index].max_speed_generation == SCIC_SDS_PARM_GEN2_SPEED) { | ||
243 | link_layer_control |= SCU_SAS_LLCTL_GEN_VAL( | ||
244 | MAX_LINK_RATE, | ||
245 | min( | ||
246 | SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2, | ||
247 | COMPILED_MAX_LINK_RATE) | ||
248 | ); | ||
249 | } else { | ||
250 | link_layer_control |= SCU_SAS_LLCTL_GEN_VAL( | ||
251 | MAX_LINK_RATE, | ||
252 | min( | ||
253 | SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1, | ||
254 | COMPILED_MAX_LINK_RATE) | ||
255 | ); | ||
256 | } | ||
257 | 213 | ||
258 | scu_link_layer_register_write( | 214 | llctl = SCU_SAS_LLCTL_GEN_VAL(NO_OUTBOUND_TASK_TIMEOUT, |
259 | this_phy, link_layer_control, link_layer_control | 215 | (u8)scic->user_parameters.sds1.no_outbound_task_timeout); |
260 | ); | ||
261 | 216 | ||
262 | /* | 217 | switch(phy_user->max_speed_generation) { |
263 | * Program the max ARB time for the PHY to 700us so we inter-operate with | 218 | case SCIC_SDS_PARM_GEN3_SPEED: |
264 | * the PMC expander which shuts down PHYs if the expander PHY generates too | 219 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN3; |
265 | * many breaks. This time value will guarantee that the initiator PHY will | 220 | break; |
266 | * generate the break. */ | 221 | case SCIC_SDS_PARM_GEN2_SPEED: |
267 | #if defined(CONFIG_PBG_HBA_A0) || defined(CONFIG_PBG_HBA_A2) | 222 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN2; |
268 | scu_link_layer_register_write( | 223 | break; |
269 | this_phy, | 224 | default: |
270 | maximum_arbitration_wait_timer_timeout, | 225 | link_rate = SCU_SAS_LINK_LAYER_CONTROL_MAX_LINK_RATE_GEN1; |
271 | SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME | 226 | break; |
272 | ); | 227 | } |
273 | #endif /* defined(CONFIG_PBG_HBA_A0) || defined(CONFIG_PBG_HBA_A2) */ | 228 | llctl |= SCU_SAS_LLCTL_GEN_VAL(MAX_LINK_RATE, link_rate); |
229 | |||
230 | scu_link_layer_register_write(sci_phy, link_layer_control, llctl); | ||
231 | |||
232 | if (is_a0() || is_a2()) { | ||
233 | /* Program the max ARB time for the PHY to 700us so we inter-operate with | ||
234 | * the PMC expander which shuts down PHYs if the expander PHY generates too | ||
235 | * many breaks. This time value will guarantee that the initiator PHY will | ||
236 | * generate the break. | ||
237 | */ | ||
238 | scu_link_layer_register_write(sci_phy, | ||
239 | maximum_arbitration_wait_timer_timeout, | ||
240 | SCIC_SDS_PHY_MAX_ARBITRATION_WAIT_TIME); | ||
241 | } | ||
274 | 242 | ||
275 | /* | 243 | /* |
276 | * Set the link layer hang detection to 500ms (0x1F4) from its default | 244 | * Set the link layer hang detection to 500ms (0x1F4) from its default |
277 | * value of 128ms. Max value is 511 ms. */ | 245 | * value of 128ms. Max value is 511 ms. */ |
278 | scu_link_layer_register_write( | 246 | scu_link_layer_register_write(sci_phy, link_layer_hang_detection_timeout, |
279 | this_phy, link_layer_hang_detection_timeout, 0x1F4 | 247 | 0x1F4); |
280 | ); | ||
281 | 248 | ||
282 | /* We can exit the initial state to the stopped state */ | 249 | /* We can exit the initial state to the stopped state */ |
283 | sci_base_state_machine_change_state( | 250 | sci_base_state_machine_change_state(scic_sds_phy_get_base_state_machine(sci_phy), |
284 | scic_sds_phy_get_base_state_machine(this_phy), | 251 | SCI_BASE_PHY_STATE_STOPPED); |
285 | SCI_BASE_PHY_STATE_STOPPED | ||
286 | ); | ||
287 | 252 | ||
288 | return SCI_SUCCESS; | 253 | return SCI_SUCCESS; |
289 | } | 254 | } |
diff --git a/drivers/scsi/isci/sci_environment.h b/drivers/scsi/isci/sci_environment.h index e1020ee6c38e..8d57f9552e28 100644 --- a/drivers/scsi/isci/sci_environment.h +++ b/drivers/scsi/isci/sci_environment.h | |||
@@ -108,5 +108,19 @@ enum { | |||
108 | 108 | ||
109 | extern int isci_si_rev; | 109 | extern int isci_si_rev; |
110 | 110 | ||
111 | static inline bool is_a0(void) | ||
112 | { | ||
113 | return isci_si_rev == ISCI_SI_REVA0; | ||
114 | } | ||
115 | |||
116 | static inline bool is_a2(void) | ||
117 | { | ||
118 | return isci_si_rev == ISCI_SI_REVA2; | ||
119 | } | ||
120 | |||
121 | static inline bool is_b0(void) | ||
122 | { | ||
123 | return isci_si_rev > ISCI_SI_REVA2; | ||
124 | } | ||
111 | 125 | ||
112 | #endif | 126 | #endif |