2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
39 * * Neither the name of Intel Corporation nor the names of its
40 * contributors may be used to endorse or promote products derived
41 * from this software without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 #include <sys/types.h>
64 #include <asm/types.h>
68 #include "create_fw.h"
70 int write_blob(struct isci_orom *isci_orom)
76 fd = fopen(blob_name, "w+");
78 perror("Open file for write failed");
83 count = fwrite(isci_orom, sizeof(struct isci_orom), 1, fd);
85 perror("Write data failed");
95 void set_binary_values(struct isci_orom *isci_orom)
97 int c, phy_idx, port_idx;
99 /* setting OROM signature */
100 strncpy(isci_orom->hdr.signature, sig, strlen(sig));
101 isci_orom->hdr.version = version;
102 isci_orom->hdr.total_block_length = sizeof(struct isci_orom);
103 isci_orom->hdr.hdr_length = sizeof(struct sci_bios_oem_param_block_hdr);
104 isci_orom->hdr.num_elements = num_elements;
106 for (c = 0; c < 2; c++) {
107 struct sci_oem_params *ctrl = &isci_orom->ctrl[c];
108 __u8 cable_selection_mask = 0;
110 ctrl->controller.mode_type = mode_type;
111 ctrl->controller.max_concurr_spin_up = max_num_concurrent_dev_spin_up;
112 ctrl->controller.do_enable_ssc = enable_ssc;
114 for (port_idx = 0; port_idx < SCI_MAX_PORTS; port_idx++)
115 ctrl->ports[port_idx].phy_mask = phy_mask[c][port_idx];
117 for (phy_idx = 0; phy_idx < SCI_MAX_PHYS; phy_idx++) {
118 struct sci_phy_oem_params *phy = &ctrl->phys[phy_idx];
119 __u8 cable_phy = cable_selection[c][phy_idx];
121 phy->sas_address.high = sas_addr[c][phy_idx] >> 32;
122 phy->sas_address.low = sas_addr[c][phy_idx];
124 phy->afe_tx_amp_control0 = afe_tx_amp_control0;
125 phy->afe_tx_amp_control1 = afe_tx_amp_control1;
126 phy->afe_tx_amp_control2 = afe_tx_amp_control2;
127 phy->afe_tx_amp_control3 = afe_tx_amp_control3;
129 cable_selection_mask |= (cable_phy & 1) << phy_idx;
130 cable_selection_mask |= (cable_phy & 2) << (phy_idx + 3);
132 ctrl->controller.cable_selection_mask = cable_selection_mask;
139 struct isci_orom *isci_orom;
141 isci_orom = malloc(sizeof(struct isci_orom));
142 memset(isci_orom, 0, sizeof(struct isci_orom));
144 set_binary_values(isci_orom);
146 err = write_blob(isci_orom);