Skip to content

Commit d044af1

Browse files
committed
isci: Add support for probing OROM for OEM params
We need to scan the OROM for signature and grab the OEM parameters. We also need to do the same for EFI. If all fails then we resort to user binary blob, and if that fails then we go to the defaults. Share the format with the create_fw utility so that all possible sources of the parameters are in-sync. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 9affa28 commit d044af1

12 files changed

Lines changed: 453 additions & 427 deletions

File tree

‎drivers/scsi/isci/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EXTRA_CFLAGS += -Idrivers/scsi/isci/core/ -Idrivers/scsi/isci/
99
obj-$(CONFIG_SCSI_ISCI) += isci.o
1010
isci-objs := init.o phy.o request.o sata.o \
1111
remote_device.o port.o timers.o \
12-
host.o task.o events.o \
12+
host.o task.o events.o probe_roms.o \
1313
core/scic_sds_controller.o \
1414
core/scic_sds_remote_device.o \
1515
core/scic_sds_request.o \

‎drivers/scsi/isci/core/scic_config_parameters.h‎

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include "sci_status.h"
6969
#include "intel_sas.h"
7070
#include "sci_controller_constants.h"
71+
#include "probe_roms.h"
7172

7273
struct scic_sds_controller;
7374

@@ -223,44 +224,6 @@ union scic_user_parameters {
223224
*/
224225
#define SCIC_SDS_PARM_PHY_MASK_MAX 0xF
225226

226-
/**
227-
* struct scic_sds_oem_parameters - This structure delineates the various OEM
228-
* parameters that must be set the core user.
229-
*
230-
*
231-
*/
232-
struct scic_sds_oem_parameters {
233-
struct {
234-
/**
235-
* This field indicates whether Spread Spectrum Clocking (SSC)
236-
* should be enabled or disabled.
237-
*/
238-
bool do_enable_ssc;
239-
240-
} controller;
241-
242-
struct {
243-
/**
244-
* This field specifies the phys to be contained inside a port.
245-
* The bit position in the mask specifies the index of the phy
246-
* to be contained in the port. Multiple bits (i.e. phys)
247-
* can be contained in a single port.
248-
*/
249-
u8 phy_mask;
250-
251-
} ports[SCI_MAX_PORTS];
252-
253-
struct sci_phy_oem_params {
254-
/**
255-
* This field specifies the SAS address to be transmitted on
256-
* for this phy index.
257-
*/
258-
struct sci_sas_address sas_address;
259-
260-
} phys[SCI_MAX_PHYS];
261-
262-
};
263-
264227
/**
265228
* This structure/union specifies the various different OEM parameter sets
266229
* available. Each type is specific to a hardware controller version.
@@ -273,7 +236,7 @@ union scic_oem_parameters {
273236
* Storage Controller Unit (SCU) Driver Standard (SDS) version
274237
* 1.
275238
*/
276-
struct scic_sds_oem_parameters sds1;
239+
struct scic_sds_oem_params sds1;
277240

278241
};
279242

‎drivers/scsi/isci/core/scic_sds_controller.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,10 +2039,8 @@ static void scic_sds_controller_set_default_config_parameters(struct scic_sds_co
20392039

20402040
/* Initialize all of the phy parameter information. */
20412041
for (index = 0; index < SCI_MAX_PHYS; index++) {
2042-
/*
2043-
* Default to 3G (i.e. Gen 2) for now. User can override if
2044-
* they choose. */
2045-
scic->user_parameters.sds1.phys[index].max_speed_generation = 2;
2042+
/* Default to 6G (i.e. Gen 3) for now. */
2043+
scic->user_parameters.sds1.phys[index].max_speed_generation = 3;
20462044

20472045
/* the frequencies cannot be 0 */
20482046
scic->user_parameters.sds1.phys[index].align_insertion_frequency = 0x7f;

‎drivers/scsi/isci/firmware/create_fw.c‎

Lines changed: 55 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -6,157 +6,30 @@
66
#include <fcntl.h>
77
#include <string.h>
88
#include <errno.h>
9+
#include <asm/types.h>
10+
#include <strings.h>
11+
#include <stdint.h>
912

10-
char blob_name[] = "isci_firmware.bin";
11-
char id[] = "#SCU MAGIC#";
12-
unsigned char version = 1;
13-
unsigned char sub_version = 0;
14-
15-
16-
/*
17-
* For all defined arrays:
18-
* elements 0-3 are for SCU0, ports 0-3
19-
* elements 4-7 are for SCU1, ports 0-3
20-
*
21-
* valid configurations for one SCU are:
22-
* P0 P1 P2 P3
23-
* ----------------
24-
* 0xF,0x0,0x0,0x0 # 1 x4 port
25-
* 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1
26-
* # ports
27-
* 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2
28-
* # port
29-
* 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port
30-
* 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration)
31-
*
32-
* if there is a port/phy on which you do not wish to override the default
33-
* values, use the value assigned to UNINIT_PARAM (255).
34-
*/
35-
unsigned int phy_mask[] = { 1, 2, 4, 8, 1, 2, 4, 8 };
36-
37-
38-
/* denotes SAS generation. i.e. 3: SAS Gen 3 6G */
39-
unsigned int phy_gen[] = { 3, 3, 3, 3, 3, 3, 3, 3 };
40-
41-
/*
42-
* if there is a port/phy on which you do not wish to override the default
43-
* values, use the value "0000000000000000". SAS address of zero's is
44-
* considered invalid and will not be used.
45-
*/
46-
unsigned long long sas_addr[] = { 0x5FCFFFFFF0000000ULL,
47-
0x5FCFFFFFF1000000ULL,
48-
0x5FCFFFFFF2000000ULL,
49-
0x5FCFFFFFF3000000ULL,
50-
0x5FCFFFFFF4000000ULL,
51-
0x5FCFFFFFF5000000ULL,
52-
0x5FCFFFFFF6000000ULL,
53-
0x5FCFFFFFF7000000ULL };
54-
55-
int write_blob(void)
13+
#include "create_fw.h"
14+
#include "../probe_roms.h"
15+
16+
int write_blob(struct isci_orom *isci_orom)
5617
{
5718
FILE *fd;
5819
int err;
20+
size_t count;
5921

6022
fd = fopen(blob_name, "w+");
6123
if (!fd) {
6224
perror("Open file for write failed");
25+
fclose(fd);
6326
return -EIO;
6427
}
6528

66-
/* write id */
67-
err = fwrite((void *)id, sizeof(char), strlen(id)+1, fd);
68-
if (err == 0) {
69-
perror("write id failed");
70-
return err;
71-
}
72-
73-
/* write version */
74-
err = fwrite((void *)&version, sizeof(version), 1, fd);
75-
if (err == 0) {
76-
perror("write version failed");
77-
return err;
78-
}
79-
80-
/* write sub version */
81-
err = fwrite((void *)&sub_version, sizeof(sub_version), 1, fd);
82-
if (err == 0) {
83-
perror("write subversion failed");
84-
return err;
85-
}
86-
87-
/* write phy mask header */
88-
err = fputc(0x1, fd);
89-
if (err == EOF) {
90-
perror("write phy mask header failed");
91-
return -EIO;
92-
}
93-
94-
/* write size */
95-
err = fputc(8, fd);
96-
if (err == EOF) {
97-
perror("write phy mask size failed");
98-
return -EIO;
99-
}
100-
101-
/* write phy masks */
102-
err = fwrite((void *)phy_mask, 1, sizeof(phy_mask), fd);
103-
if (err == 0) {
104-
perror("write phy_mask failed");
105-
return err;
106-
}
107-
108-
/* write phy gen header */
109-
err = fputc(0x2, fd);
110-
if (err == EOF) {
111-
perror("write phy gen header failed");
112-
return -EIO;
113-
}
114-
115-
/* write size */
116-
err = fputc(8, fd);
117-
if (err == EOF) {
118-
perror("write phy gen size failed");
119-
return -EIO;
120-
}
121-
122-
/* write phy_gen */
123-
err = fwrite((void *)phy_gen,
124-
1,
125-
sizeof(phy_gen),
126-
fd);
127-
if (err == 0) {
128-
perror("write phy_gen failed");
129-
return err;
130-
}
131-
132-
/* write phy gen header */
133-
err = fputc(0x3, fd);
134-
if (err == EOF) {
135-
perror("write sas addr header failed");
136-
return -EIO;
137-
}
138-
139-
/* write size */
140-
err = fputc(8, fd);
141-
if (err == EOF) {
142-
perror("write sas addr size failed");
143-
return -EIO;
144-
}
145-
146-
/* write sas_addr */
147-
err = fwrite((void *)sas_addr,
148-
1,
149-
sizeof(sas_addr),
150-
fd);
151-
if (err == 0) {
152-
perror("write sas_addr failed");
153-
return err;
154-
}
155-
156-
/* write end header */
157-
err = fputc(0xff, fd);
158-
if (err == EOF) {
159-
perror("write end header failed");
29+
count = fwrite(isci_orom, sizeof(struct isci_orom), 1, fd);
30+
if (count != 1) {
31+
perror("Write data failed");
32+
fclose(fd);
16033
return -EIO;
16134
}
16235

@@ -165,13 +38,53 @@ int write_blob(void)
16538
return 0;
16639
}
16740

41+
void set_binary_values(struct isci_orom *isci_orom)
42+
{
43+
int ctrl_idx, phy_idx, port_idx;
44+
45+
/* setting OROM signature */
46+
strncpy(isci_orom->hdr.signature, sig, strlen(sig));
47+
isci_orom->hdr.version = 0x10;
48+
isci_orom->hdr.total_block_length = sizeof(struct isci_orom);
49+
isci_orom->hdr.hdr_length = sizeof(struct sci_bios_oem_param_block_hdr);
50+
isci_orom->hdr.num_elements = num_elements;
51+
52+
for (ctrl_idx = 0; ctrl_idx < 2; ctrl_idx++) {
53+
isci_orom->ctrl[ctrl_idx].controller.mode_type = mode_type;
54+
isci_orom->ctrl[ctrl_idx].controller.max_concurrent_dev_spin_up =
55+
max_num_concurrent_dev_spin_up;
56+
isci_orom->ctrl[ctrl_idx].controller.do_enable_ssc =
57+
enable_ssc;
58+
59+
for (port_idx = 0; port_idx < 4; port_idx++)
60+
isci_orom->ctrl[ctrl_idx].ports[port_idx].phy_mask =
61+
phy_mask[ctrl_idx][port_idx];
62+
63+
for (phy_idx = 0; phy_idx < 4; phy_idx++) {
64+
isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.high =
65+
(__u32)(sas_addr[ctrl_idx][phy_idx] >> 32);
66+
isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.low =
67+
(__u32)(sas_addr[ctrl_idx][phy_idx]);
68+
}
69+
}
70+
}
71+
16872
int main(void)
16973
{
17074
int err;
75+
struct isci_orom *isci_orom;
76+
77+
isci_orom = malloc(sizeof(struct isci_orom));
78+
memset(isci_orom, 0, sizeof(struct isci_orom));
17179

172-
err = write_blob();
173-
if (err < 0)
80+
set_binary_values(isci_orom);
81+
82+
err = write_blob(isci_orom);
83+
if (err < 0) {
84+
free(isci_orom);
17485
return err;
86+
}
17587

88+
free(isci_orom);
17689
return 0;
17790
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#ifndef _CREATE_FW_H_
2+
#define _CREATE_FW_H_
3+
4+
5+
/* we are configuring for 2 SCUs */
6+
static const int num_elements = 2;
7+
8+
/*
9+
* For all defined arrays:
10+
* elements 0-3 are for SCU0, ports 0-3
11+
* elements 4-7 are for SCU1, ports 0-3
12+
*
13+
* valid configurations for one SCU are:
14+
* P0 P1 P2 P3
15+
* ----------------
16+
* 0xF,0x0,0x0,0x0 # 1 x4 port
17+
* 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1
18+
* # ports
19+
* 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2
20+
* # port
21+
* 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port
22+
* 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration)
23+
*
24+
* if there is a port/phy on which you do not wish to override the default
25+
* values, use the value assigned to UNINIT_PARAM (255).
26+
*/
27+
#ifdef MPC
28+
static const __u8 phy_mask[2][4] = { {1, 2, 4, 8},
29+
{1, 2, 4, 8} };
30+
#else /* APC (default) */
31+
static const __u8 phy_mask[2][4];
32+
#endif
33+
34+
/* discovery mode type (port auto config mode by default ) */
35+
static const int mode_type;
36+
37+
/* Maximum number of concurrent device spin up */
38+
static const int max_num_concurrent_dev_spin_up = 1;
39+
40+
/* enable of ssc operation */
41+
static const int enable_ssc;
42+
43+
/* AFE_TX_AMP_CONTROL */
44+
static const unsigned int afe_tx_amp_control0 = 0x000e7c03;
45+
static const unsigned int afe_tx_amp_control1 = 0x000e7c03;
46+
static const unsigned int afe_tx_amp_control2 = 0x000e7c03;
47+
static const unsigned int afe_tx_amp_control3 = 0x000e7c03;
48+
49+
/*
50+
* if there is a port/phy on which you do not wish to override the default
51+
* values, use the value "0000000000000000". SAS address of zero's is
52+
* considered invalid and will not be used.
53+
*/
54+
static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFFF0000000ULL,
55+
0x5FCFFFFFF1000000ULL,
56+
0x5FCFFFFFF2000000ULL,
57+
0x5FCFFFFFF3000000ULL },
58+
{ 0x5FCFFFFFF4000000ULL,
59+
0x5FCFFFFFF5000000ULL,
60+
0x5FCFFFFFF6000000ULL,
61+
0x5FCFFFFFF7000000ULL } };
62+
63+
static const char blob_name[] = "isci_firmware.bin";
64+
static const char sig[] = "ISCUOEMB";
65+
static const unsigned char version = 1;
66+
67+
#endif

0 commit comments

Comments
 (0)