diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/scsi/isci | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'drivers/scsi/isci')
| -rw-r--r-- | drivers/scsi/isci/firmware/Makefile | 19 | ||||
| -rw-r--r-- | drivers/scsi/isci/firmware/README | 36 | ||||
| -rw-r--r-- | drivers/scsi/isci/firmware/create_fw.c | 99 | ||||
| -rw-r--r-- | drivers/scsi/isci/firmware/create_fw.h | 77 |
4 files changed, 231 insertions, 0 deletions
diff --git a/drivers/scsi/isci/firmware/Makefile b/drivers/scsi/isci/firmware/Makefile new file mode 100644 index 00000000000..5f54461cabc --- /dev/null +++ b/drivers/scsi/isci/firmware/Makefile | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | # Makefile for create_fw | ||
| 2 | # | ||
| 3 | CC=gcc | ||
| 4 | CFLAGS=-c -Wall -O2 -g | ||
| 5 | LDFLAGS= | ||
| 6 | SOURCES=create_fw.c | ||
| 7 | OBJECTS=$(SOURCES:.cpp=.o) | ||
| 8 | EXECUTABLE=create_fw | ||
| 9 | |||
| 10 | all: $(SOURCES) $(EXECUTABLE) | ||
| 11 | |||
| 12 | $(EXECUTABLE): $(OBJECTS) | ||
| 13 | $(CC) $(LDFLAGS) $(OBJECTS) -o $@ | ||
| 14 | |||
| 15 | .c.o: | ||
| 16 | $(CC) $(CFLAGS) $< -O $@ | ||
| 17 | |||
| 18 | clean: | ||
| 19 | rm -f *.o $(EXECUTABLE) | ||
diff --git a/drivers/scsi/isci/firmware/README b/drivers/scsi/isci/firmware/README new file mode 100644 index 00000000000..8056d2bd233 --- /dev/null +++ b/drivers/scsi/isci/firmware/README | |||
| @@ -0,0 +1,36 @@ | |||
| 1 | This defines the temporary binary blow we are to pass to the SCU | ||
| 2 | driver to emulate the binary firmware that we will eventually be | ||
| 3 | able to access via NVRAM on the SCU controller. | ||
| 4 | |||
| 5 | The current size of the binary blob is expected to be 149 bytes or larger | ||
| 6 | |||
| 7 | Header Types: | ||
| 8 | 0x1: Phy Masks | ||
| 9 | 0x2: Phy Gens | ||
| 10 | 0x3: SAS Addrs | ||
| 11 | 0xff: End of Data | ||
| 12 | |||
| 13 | ID string - u8[12]: "#SCU MAGIC#\0" | ||
| 14 | Version - u8: 1 | ||
| 15 | SubVersion - u8: 0 | ||
| 16 | |||
| 17 | Header Type - u8: 0x1 | ||
| 18 | Size - u8: 8 | ||
| 19 | Phy Mask - u32[8] | ||
| 20 | |||
| 21 | Header Type - u8: 0x2 | ||
| 22 | Size - u8: 8 | ||
| 23 | Phy Gen - u32[8] | ||
| 24 | |||
| 25 | Header Type - u8: 0x3 | ||
| 26 | Size - u8: 8 | ||
| 27 | Sas Addr - u64[8] | ||
| 28 | |||
| 29 | Header Type - u8: 0xf | ||
| 30 | |||
| 31 | |||
| 32 | ============================================================================== | ||
| 33 | |||
| 34 | Place isci_firmware.bin in /lib/firmware | ||
| 35 | Be sure to recreate the initramfs image to include the firmware. | ||
| 36 | |||
diff --git a/drivers/scsi/isci/firmware/create_fw.c b/drivers/scsi/isci/firmware/create_fw.c new file mode 100644 index 00000000000..c7a2887a7e9 --- /dev/null +++ b/drivers/scsi/isci/firmware/create_fw.c | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <unistd.h> | ||
| 4 | #include <sys/types.h> | ||
| 5 | #include <sys/stat.h> | ||
| 6 | #include <fcntl.h> | ||
| 7 | #include <string.h> | ||
| 8 | #include <errno.h> | ||
| 9 | #include <asm/types.h> | ||
| 10 | #include <strings.h> | ||
| 11 | #include <stdint.h> | ||
| 12 | |||
| 13 | #include "create_fw.h" | ||
| 14 | #include "../probe_roms.h" | ||
| 15 | |||
| 16 | int write_blob(struct isci_orom *isci_orom) | ||
| 17 | { | ||
| 18 | FILE *fd; | ||
| 19 | int err; | ||
| 20 | size_t count; | ||
| 21 | |||
| 22 | fd = fopen(blob_name, "w+"); | ||
| 23 | if (!fd) { | ||
| 24 | perror("Open file for write failed"); | ||
| 25 | fclose(fd); | ||
| 26 | return -EIO; | ||
| 27 | } | ||
| 28 | |||
| 29 | count = fwrite(isci_orom, sizeof(struct isci_orom), 1, fd); | ||
| 30 | if (count != 1) { | ||
| 31 | perror("Write data failed"); | ||
| 32 | fclose(fd); | ||
| 33 | return -EIO; | ||
| 34 | } | ||
| 35 | |||
| 36 | fclose(fd); | ||
| 37 | |||
| 38 | return 0; | ||
| 39 | } | ||
| 40 | |||
| 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 = version; | ||
| 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 | isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control0 = | ||
| 70 | afe_tx_amp_control0; | ||
| 71 | isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control1 = | ||
| 72 | afe_tx_amp_control1; | ||
| 73 | isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control2 = | ||
| 74 | afe_tx_amp_control2; | ||
| 75 | isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control3 = | ||
| 76 | afe_tx_amp_control3; | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | int main(void) | ||
| 82 | { | ||
| 83 | int err; | ||
| 84 | struct isci_orom *isci_orom; | ||
| 85 | |||
| 86 | isci_orom = malloc(sizeof(struct isci_orom)); | ||
| 87 | memset(isci_orom, 0, sizeof(struct isci_orom)); | ||
| 88 | |||
| 89 | set_binary_values(isci_orom); | ||
| 90 | |||
| 91 | err = write_blob(isci_orom); | ||
| 92 | if (err < 0) { | ||
| 93 | free(isci_orom); | ||
| 94 | return err; | ||
| 95 | } | ||
| 96 | |||
| 97 | free(isci_orom); | ||
| 98 | return 0; | ||
| 99 | } | ||
diff --git a/drivers/scsi/isci/firmware/create_fw.h b/drivers/scsi/isci/firmware/create_fw.h new file mode 100644 index 00000000000..5f298828d22 --- /dev/null +++ b/drivers/scsi/isci/firmware/create_fw.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | #ifndef _CREATE_FW_H_ | ||
| 2 | #define _CREATE_FW_H_ | ||
| 3 | #include "../probe_roms.h" | ||
| 4 | |||
| 5 | |||
| 6 | /* we are configuring for 2 SCUs */ | ||
| 7 | static const int num_elements = 2; | ||
| 8 | |||
| 9 | /* | ||
| 10 | * For all defined arrays: | ||
| 11 | * elements 0-3 are for SCU0, ports 0-3 | ||
| 12 | * elements 4-7 are for SCU1, ports 0-3 | ||
| 13 | * | ||
| 14 | * valid configurations for one SCU are: | ||
| 15 | * P0 P1 P2 P3 | ||
| 16 | * ---------------- | ||
| 17 | * 0xF,0x0,0x0,0x0 # 1 x4 port | ||
| 18 | * 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1 | ||
| 19 | * # ports | ||
| 20 | * 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2 | ||
| 21 | * # port | ||
| 22 | * 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port | ||
| 23 | * 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration) | ||
| 24 | * | ||
| 25 | * if there is a port/phy on which you do not wish to override the default | ||
| 26 | * values, use the value assigned to UNINIT_PARAM (255). | ||
| 27 | */ | ||
| 28 | |||
| 29 | /* discovery mode type (port auto config mode by default ) */ | ||
| 30 | |||
| 31 | /* | ||
| 32 | * if there is a port/phy on which you do not wish to override the default | ||
| 33 | * values, use the value "0000000000000000". SAS address of zero's is | ||
| 34 | * considered invalid and will not be used. | ||
| 35 | */ | ||
| 36 | #ifdef MPC | ||
| 37 | static const int mode_type = SCIC_PORT_MANUAL_CONFIGURATION_MODE; | ||
| 38 | static const __u8 phy_mask[2][4] = { {1, 2, 4, 8}, | ||
| 39 | {1, 2, 4, 8} }; | ||
| 40 | static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFFF0000001ULL, | ||
| 41 | 0x5FCFFFFFF0000002ULL, | ||
| 42 | 0x5FCFFFFFF0000003ULL, | ||
| 43 | 0x5FCFFFFFF0000004ULL }, | ||
| 44 | { 0x5FCFFFFFF0000005ULL, | ||
| 45 | 0x5FCFFFFFF0000006ULL, | ||
| 46 | 0x5FCFFFFFF0000007ULL, | ||
| 47 | 0x5FCFFFFFF0000008ULL } }; | ||
| 48 | #else /* APC (default) */ | ||
| 49 | static const int mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE; | ||
| 50 | static const __u8 phy_mask[2][4]; | ||
| 51 | static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFF00000001ULL, | ||
| 52 | 0x5FCFFFFF00000001ULL, | ||
| 53 | 0x5FCFFFFF00000001ULL, | ||
| 54 | 0x5FCFFFFF00000001ULL }, | ||
| 55 | { 0x5FCFFFFF00000002ULL, | ||
| 56 | 0x5FCFFFFF00000002ULL, | ||
| 57 | 0x5FCFFFFF00000002ULL, | ||
| 58 | 0x5FCFFFFF00000002ULL } }; | ||
| 59 | #endif | ||
| 60 | |||
| 61 | /* Maximum number of concurrent device spin up */ | ||
| 62 | static const int max_num_concurrent_dev_spin_up = 1; | ||
| 63 | |||
| 64 | /* enable of ssc operation */ | ||
| 65 | static const int enable_ssc; | ||
| 66 | |||
| 67 | /* AFE_TX_AMP_CONTROL */ | ||
| 68 | static const unsigned int afe_tx_amp_control0 = 0x000bdd08; | ||
| 69 | static const unsigned int afe_tx_amp_control1 = 0x000ffc00; | ||
| 70 | static const unsigned int afe_tx_amp_control2 = 0x000b7c09; | ||
| 71 | static const unsigned int afe_tx_amp_control3 = 0x000afc6e; | ||
| 72 | |||
| 73 | static const char blob_name[] = "isci_firmware.bin"; | ||
| 74 | static const char sig[] = "ISCUOEMB"; | ||
| 75 | static const unsigned char version = 0x10; | ||
| 76 | |||
| 77 | #endif | ||
