jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 1 | /* |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 2 | * PMC-Sierra 8001/8081/8088/8089 SAS/SATA based host adapters driver |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (c) 2008-2009 USI Co., Ltd. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions, and the following disclaimer, |
| 12 | * without modification. |
| 13 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 14 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 15 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 16 | * including a substantially similar Disclaimer requirement for further |
| 17 | * binary redistribution. |
| 18 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 19 | * of any contributors may be used to endorse or promote products derived |
| 20 | * from this software without specific prior written permission. |
| 21 | * |
| 22 | * Alternatively, this software may be distributed under the terms of the |
| 23 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 24 | * Software Foundation. |
| 25 | * |
| 26 | * NO WARRANTY |
| 27 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 28 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 29 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 30 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 31 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 32 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 35 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 36 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 37 | * POSSIBILITY OF SUCH DAMAGES. |
| 38 | * |
| 39 | */ |
| 40 | #include <linux/firmware.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 41 | #include <linux/slab.h> |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 42 | #include "pm8001_sas.h" |
| 43 | #include "pm8001_ctl.h" |
| 44 | |
| 45 | /* scsi host attributes */ |
| 46 | |
| 47 | /** |
| 48 | * pm8001_ctl_mpi_interface_rev_show - MPI interface revision number |
| 49 | * @cdev: pointer to embedded class device |
| 50 | * @buf: the buffer returned |
| 51 | * |
| 52 | * A sysfs 'read-only' shost attribute. |
| 53 | */ |
| 54 | static ssize_t pm8001_ctl_mpi_interface_rev_show(struct device *cdev, |
| 55 | struct device_attribute *attr, char *buf) |
| 56 | { |
| 57 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 58 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 59 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 60 | |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 61 | if (pm8001_ha->chip_id == chip_8001) { |
| 62 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 63 | pm8001_ha->main_cfg_tbl.pm8001_tbl.interface_rev); |
| 64 | } else { |
| 65 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 66 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.interface_rev); |
| 67 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 68 | } |
| 69 | static |
| 70 | DEVICE_ATTR(interface_rev, S_IRUGO, pm8001_ctl_mpi_interface_rev_show, NULL); |
| 71 | |
| 72 | /** |
| 73 | * pm8001_ctl_fw_version_show - firmware version |
| 74 | * @cdev: pointer to embedded class device |
| 75 | * @buf: the buffer returned |
| 76 | * |
| 77 | * A sysfs 'read-only' shost attribute. |
| 78 | */ |
| 79 | static ssize_t pm8001_ctl_fw_version_show(struct device *cdev, |
| 80 | struct device_attribute *attr, char *buf) |
| 81 | { |
| 82 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 83 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 84 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 85 | |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 86 | if (pm8001_ha->chip_id == chip_8001) { |
| 87 | return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", |
| 88 | (u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 24), |
| 89 | (u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 16), |
| 90 | (u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev >> 8), |
| 91 | (u8)(pm8001_ha->main_cfg_tbl.pm8001_tbl.firmware_rev)); |
| 92 | } else { |
| 93 | return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", |
| 94 | (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 24), |
| 95 | (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 16), |
| 96 | (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev >> 8), |
| 97 | (u8)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev)); |
| 98 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 99 | } |
| 100 | static DEVICE_ATTR(fw_version, S_IRUGO, pm8001_ctl_fw_version_show, NULL); |
| 101 | /** |
| 102 | * pm8001_ctl_max_out_io_show - max outstanding io supported |
| 103 | * @cdev: pointer to embedded class device |
| 104 | * @buf: the buffer returned |
| 105 | * |
| 106 | * A sysfs 'read-only' shost attribute. |
| 107 | */ |
| 108 | static ssize_t pm8001_ctl_max_out_io_show(struct device *cdev, |
| 109 | struct device_attribute *attr, char *buf) |
| 110 | { |
| 111 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 112 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 113 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 114 | |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 115 | if (pm8001_ha->chip_id == chip_8001) { |
| 116 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 117 | pm8001_ha->main_cfg_tbl.pm8001_tbl.max_out_io); |
| 118 | } else { |
| 119 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 120 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io); |
| 121 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 122 | } |
| 123 | static DEVICE_ATTR(max_out_io, S_IRUGO, pm8001_ctl_max_out_io_show, NULL); |
| 124 | /** |
| 125 | * pm8001_ctl_max_devices_show - max devices support |
| 126 | * @cdev: pointer to embedded class device |
| 127 | * @buf: the buffer returned |
| 128 | * |
| 129 | * A sysfs 'read-only' shost attribute. |
| 130 | */ |
| 131 | static ssize_t pm8001_ctl_max_devices_show(struct device *cdev, |
| 132 | struct device_attribute *attr, char *buf) |
| 133 | { |
| 134 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 135 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 136 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 137 | |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 138 | if (pm8001_ha->chip_id == chip_8001) { |
| 139 | return snprintf(buf, PAGE_SIZE, "%04d\n", |
| 140 | (u16)(pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl >> 16) |
| 141 | ); |
| 142 | } else { |
| 143 | return snprintf(buf, PAGE_SIZE, "%04d\n", |
| 144 | (u16)(pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl >> 16) |
| 145 | ); |
| 146 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 147 | } |
| 148 | static DEVICE_ATTR(max_devices, S_IRUGO, pm8001_ctl_max_devices_show, NULL); |
| 149 | /** |
| 150 | * pm8001_ctl_max_sg_list_show - max sg list supported iff not 0.0 for no |
| 151 | * hardware limitation |
| 152 | * @cdev: pointer to embedded class device |
| 153 | * @buf: the buffer returned |
| 154 | * |
| 155 | * A sysfs 'read-only' shost attribute. |
| 156 | */ |
| 157 | static ssize_t pm8001_ctl_max_sg_list_show(struct device *cdev, |
| 158 | struct device_attribute *attr, char *buf) |
| 159 | { |
| 160 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 161 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 162 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 163 | |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 164 | if (pm8001_ha->chip_id == chip_8001) { |
| 165 | return snprintf(buf, PAGE_SIZE, "%04d\n", |
| 166 | pm8001_ha->main_cfg_tbl.pm8001_tbl.max_sgl & 0x0000FFFF |
| 167 | ); |
| 168 | } else { |
| 169 | return snprintf(buf, PAGE_SIZE, "%04d\n", |
| 170 | pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl & 0x0000FFFF |
| 171 | ); |
| 172 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 173 | } |
| 174 | static DEVICE_ATTR(max_sg_list, S_IRUGO, pm8001_ctl_max_sg_list_show, NULL); |
| 175 | |
| 176 | #define SAS_1_0 0x1 |
| 177 | #define SAS_1_1 0x2 |
| 178 | #define SAS_2_0 0x4 |
| 179 | |
| 180 | static ssize_t |
| 181 | show_sas_spec_support_status(unsigned int mode, char *buf) |
| 182 | { |
| 183 | ssize_t len = 0; |
| 184 | |
| 185 | if (mode & SAS_1_1) |
| 186 | len = sprintf(buf, "%s", "SAS1.1"); |
| 187 | if (mode & SAS_2_0) |
| 188 | len += sprintf(buf + len, "%s%s", len ? ", " : "", "SAS2.0"); |
| 189 | len += sprintf(buf + len, "\n"); |
| 190 | |
| 191 | return len; |
| 192 | } |
| 193 | |
| 194 | /** |
| 195 | * pm8001_ctl_sas_spec_support_show - sas spec supported |
| 196 | * @cdev: pointer to embedded class device |
| 197 | * @buf: the buffer returned |
| 198 | * |
| 199 | * A sysfs 'read-only' shost attribute. |
| 200 | */ |
| 201 | static ssize_t pm8001_ctl_sas_spec_support_show(struct device *cdev, |
| 202 | struct device_attribute *attr, char *buf) |
| 203 | { |
| 204 | unsigned int mode; |
| 205 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 206 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 207 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
Sakthivel K | e574210 | 2013-04-17 16:26:36 +0530 | [diff] [blame] | 208 | /* fe000000 means supports SAS2.1 */ |
| 209 | if (pm8001_ha->chip_id == chip_8001) |
| 210 | mode = (pm8001_ha->main_cfg_tbl.pm8001_tbl.ctrl_cap_flag & |
| 211 | 0xfe000000)>>25; |
| 212 | else |
| 213 | /* fe000000 means supports SAS2.1 */ |
| 214 | mode = (pm8001_ha->main_cfg_tbl.pm80xx_tbl.ctrl_cap_flag & |
| 215 | 0xfe000000)>>25; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 216 | return show_sas_spec_support_status(mode, buf); |
| 217 | } |
| 218 | static DEVICE_ATTR(sas_spec_support, S_IRUGO, |
| 219 | pm8001_ctl_sas_spec_support_show, NULL); |
| 220 | |
| 221 | /** |
| 222 | * pm8001_ctl_sas_address_show - sas address |
| 223 | * @cdev: pointer to embedded class device |
| 224 | * @buf: the buffer returned |
| 225 | * |
| 226 | * This is the controller sas address |
| 227 | * |
| 228 | * A sysfs 'read-only' shost attribute. |
| 229 | */ |
| 230 | static ssize_t pm8001_ctl_host_sas_address_show(struct device *cdev, |
| 231 | struct device_attribute *attr, char *buf) |
| 232 | { |
| 233 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 234 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 235 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 236 | return snprintf(buf, PAGE_SIZE, "0x%016llx\n", |
| 237 | be64_to_cpu(*(__be64 *)pm8001_ha->sas_addr)); |
| 238 | } |
| 239 | static DEVICE_ATTR(host_sas_address, S_IRUGO, |
| 240 | pm8001_ctl_host_sas_address_show, NULL); |
| 241 | |
| 242 | /** |
| 243 | * pm8001_ctl_logging_level_show - logging level |
| 244 | * @cdev: pointer to embedded class device |
| 245 | * @buf: the buffer returned |
| 246 | * |
| 247 | * A sysfs 'read/write' shost attribute. |
| 248 | */ |
| 249 | static ssize_t pm8001_ctl_logging_level_show(struct device *cdev, |
| 250 | struct device_attribute *attr, char *buf) |
| 251 | { |
| 252 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 253 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 254 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 255 | |
| 256 | return snprintf(buf, PAGE_SIZE, "%08xh\n", pm8001_ha->logging_level); |
| 257 | } |
| 258 | static ssize_t pm8001_ctl_logging_level_store(struct device *cdev, |
| 259 | struct device_attribute *attr, const char *buf, size_t count) |
| 260 | { |
| 261 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 262 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 263 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 264 | int val = 0; |
| 265 | |
| 266 | if (sscanf(buf, "%x", &val) != 1) |
| 267 | return -EINVAL; |
| 268 | |
| 269 | pm8001_ha->logging_level = val; |
| 270 | return strlen(buf); |
| 271 | } |
| 272 | |
| 273 | static DEVICE_ATTR(logging_level, S_IRUGO | S_IWUSR, |
| 274 | pm8001_ctl_logging_level_show, pm8001_ctl_logging_level_store); |
| 275 | /** |
| 276 | * pm8001_ctl_aap_log_show - aap1 event log |
| 277 | * @cdev: pointer to embedded class device |
| 278 | * @buf: the buffer returned |
| 279 | * |
| 280 | * A sysfs 'read-only' shost attribute. |
| 281 | */ |
| 282 | static ssize_t pm8001_ctl_aap_log_show(struct device *cdev, |
| 283 | struct device_attribute *attr, char *buf) |
| 284 | { |
| 285 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 286 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 287 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 288 | int i; |
| 289 | #define AAP1_MEMMAP(r, c) \ |
| 290 | (*(u32 *)((u8*)pm8001_ha->memoryMap.region[AAP1].virt_ptr + (r) * 32 \ |
| 291 | + (c))) |
| 292 | |
| 293 | char *str = buf; |
| 294 | int max = 2; |
| 295 | for (i = 0; i < max; i++) { |
| 296 | str += sprintf(str, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x" |
| 297 | "0x%08x 0x%08x\n", |
| 298 | AAP1_MEMMAP(i, 0), |
| 299 | AAP1_MEMMAP(i, 4), |
| 300 | AAP1_MEMMAP(i, 8), |
| 301 | AAP1_MEMMAP(i, 12), |
| 302 | AAP1_MEMMAP(i, 16), |
| 303 | AAP1_MEMMAP(i, 20), |
| 304 | AAP1_MEMMAP(i, 24), |
| 305 | AAP1_MEMMAP(i, 28)); |
| 306 | } |
| 307 | |
| 308 | return str - buf; |
| 309 | } |
| 310 | static DEVICE_ATTR(aap_log, S_IRUGO, pm8001_ctl_aap_log_show, NULL); |
| 311 | /** |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 312 | * pm8001_ctl_ib_queue_log_show - Out bound Queue log |
| 313 | * @cdev:pointer to embedded class device |
| 314 | * @buf: the buffer returned |
| 315 | * A sysfs 'read-only' shost attribute. |
| 316 | */ |
| 317 | static ssize_t pm8001_ctl_ib_queue_log_show(struct device *cdev, |
| 318 | struct device_attribute *attr, char *buf) |
| 319 | { |
| 320 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 321 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 322 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 323 | int offset; |
| 324 | char *str = buf; |
| 325 | int start = 0; |
Viswas G | 859b5d1 | 2013-12-10 10:31:28 +0530 | [diff] [blame] | 326 | #define IB_MEMMAP(c) \ |
| 327 | (*(u32 *)((u8 *)pm8001_ha-> \ |
| 328 | memoryMap.region[IB].virt_ptr + \ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 329 | pm8001_ha->evtlog_ib_offset + (c))) |
| 330 | |
| 331 | for (offset = 0; offset < IB_OB_READ_TIMES; offset++) { |
Viswas G | 859b5d1 | 2013-12-10 10:31:28 +0530 | [diff] [blame] | 332 | str += sprintf(str, "0x%08x\n", IB_MEMMAP(start)); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 333 | start = start + 4; |
| 334 | } |
| 335 | pm8001_ha->evtlog_ib_offset += SYSFS_OFFSET; |
Viswas G | 859b5d1 | 2013-12-10 10:31:28 +0530 | [diff] [blame] | 336 | if (((pm8001_ha->evtlog_ib_offset) % (PM80XX_IB_OB_QUEUE_SIZE)) == 0) |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 337 | pm8001_ha->evtlog_ib_offset = 0; |
| 338 | |
| 339 | return str - buf; |
| 340 | } |
| 341 | |
| 342 | static DEVICE_ATTR(ib_log, S_IRUGO, pm8001_ctl_ib_queue_log_show, NULL); |
| 343 | /** |
| 344 | * pm8001_ctl_ob_queue_log_show - Out bound Queue log |
| 345 | * @cdev:pointer to embedded class device |
| 346 | * @buf: the buffer returned |
| 347 | * A sysfs 'read-only' shost attribute. |
| 348 | */ |
| 349 | |
| 350 | static ssize_t pm8001_ctl_ob_queue_log_show(struct device *cdev, |
| 351 | struct device_attribute *attr, char *buf) |
| 352 | { |
| 353 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 354 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 355 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 356 | int offset; |
| 357 | char *str = buf; |
| 358 | int start = 0; |
Viswas G | 859b5d1 | 2013-12-10 10:31:28 +0530 | [diff] [blame] | 359 | #define OB_MEMMAP(c) \ |
| 360 | (*(u32 *)((u8 *)pm8001_ha-> \ |
| 361 | memoryMap.region[OB].virt_ptr + \ |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 362 | pm8001_ha->evtlog_ob_offset + (c))) |
| 363 | |
| 364 | for (offset = 0; offset < IB_OB_READ_TIMES; offset++) { |
Viswas G | 859b5d1 | 2013-12-10 10:31:28 +0530 | [diff] [blame] | 365 | str += sprintf(str, "0x%08x\n", OB_MEMMAP(start)); |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 366 | start = start + 4; |
| 367 | } |
| 368 | pm8001_ha->evtlog_ob_offset += SYSFS_OFFSET; |
Viswas G | 859b5d1 | 2013-12-10 10:31:28 +0530 | [diff] [blame] | 369 | if (((pm8001_ha->evtlog_ob_offset) % (PM80XX_IB_OB_QUEUE_SIZE)) == 0) |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 370 | pm8001_ha->evtlog_ob_offset = 0; |
| 371 | |
| 372 | return str - buf; |
| 373 | } |
| 374 | static DEVICE_ATTR(ob_log, S_IRUGO, pm8001_ctl_ob_queue_log_show, NULL); |
| 375 | /** |
Anand Kumar Santhanam | 966fdcf | 2013-09-18 12:54:41 +0530 | [diff] [blame] | 376 | * pm8001_ctl_bios_version_show - Bios version Display |
| 377 | * @cdev:pointer to embedded class device |
| 378 | * @buf:the buffer returned |
| 379 | * A sysfs 'read-only' shost attribute. |
| 380 | */ |
| 381 | static ssize_t pm8001_ctl_bios_version_show(struct device *cdev, |
| 382 | struct device_attribute *attr, char *buf) |
| 383 | { |
| 384 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 385 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 386 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 387 | char *str = buf; |
Anand Kumar Santhanam | 966fdcf | 2013-09-18 12:54:41 +0530 | [diff] [blame] | 388 | int bios_index; |
| 389 | DECLARE_COMPLETION_ONSTACK(completion); |
| 390 | struct pm8001_ioctl_payload payload; |
| 391 | |
| 392 | pm8001_ha->nvmd_completion = &completion; |
| 393 | payload.minor_function = 7; |
| 394 | payload.offset = 0; |
| 395 | payload.length = 4096; |
| 396 | payload.func_specific = kzalloc(4096, GFP_KERNEL); |
Suresh Thiagarajan | b42939a | 2014-05-09 11:31:01 +0530 | [diff] [blame] | 397 | if (!payload.func_specific) |
| 398 | return -ENOMEM; |
Tomas Henzl | 5b4ce88 | 2014-07-09 17:21:11 +0530 | [diff] [blame] | 399 | if (PM8001_CHIP_DISP->get_nvmd_req(pm8001_ha, &payload)) { |
| 400 | kfree(payload.func_specific); |
| 401 | return -ENOMEM; |
| 402 | } |
Anand Kumar Santhanam | 966fdcf | 2013-09-18 12:54:41 +0530 | [diff] [blame] | 403 | wait_for_completion(&completion); |
Anand Kumar Santhanam | 966fdcf | 2013-09-18 12:54:41 +0530 | [diff] [blame] | 404 | for (bios_index = BIOSOFFSET; bios_index < BIOS_OFFSET_LIMIT; |
| 405 | bios_index++) |
| 406 | str += sprintf(str, "%c", |
Suresh Thiagarajan | 9e03284 | 2014-08-11 11:50:35 +0530 | [diff] [blame] | 407 | *(payload.func_specific+bios_index)); |
Suresh Thiagarajan | b42939a | 2014-05-09 11:31:01 +0530 | [diff] [blame] | 408 | kfree(payload.func_specific); |
Anand Kumar Santhanam | 966fdcf | 2013-09-18 12:54:41 +0530 | [diff] [blame] | 409 | return str - buf; |
| 410 | } |
| 411 | static DEVICE_ATTR(bios_version, S_IRUGO, pm8001_ctl_bios_version_show, NULL); |
| 412 | /** |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 413 | * pm8001_ctl_aap_log_show - IOP event log |
| 414 | * @cdev: pointer to embedded class device |
| 415 | * @buf: the buffer returned |
| 416 | * |
| 417 | * A sysfs 'read-only' shost attribute. |
| 418 | */ |
| 419 | static ssize_t pm8001_ctl_iop_log_show(struct device *cdev, |
| 420 | struct device_attribute *attr, char *buf) |
| 421 | { |
| 422 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 423 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 424 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 425 | #define IOP_MEMMAP(r, c) \ |
| 426 | (*(u32 *)((u8*)pm8001_ha->memoryMap.region[IOP].virt_ptr + (r) * 32 \ |
| 427 | + (c))) |
| 428 | int i; |
| 429 | char *str = buf; |
| 430 | int max = 2; |
| 431 | for (i = 0; i < max; i++) { |
| 432 | str += sprintf(str, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x" |
| 433 | "0x%08x 0x%08x\n", |
| 434 | IOP_MEMMAP(i, 0), |
| 435 | IOP_MEMMAP(i, 4), |
| 436 | IOP_MEMMAP(i, 8), |
| 437 | IOP_MEMMAP(i, 12), |
| 438 | IOP_MEMMAP(i, 16), |
| 439 | IOP_MEMMAP(i, 20), |
| 440 | IOP_MEMMAP(i, 24), |
| 441 | IOP_MEMMAP(i, 28)); |
| 442 | } |
| 443 | |
| 444 | return str - buf; |
| 445 | } |
| 446 | static DEVICE_ATTR(iop_log, S_IRUGO, pm8001_ctl_iop_log_show, NULL); |
| 447 | |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 448 | /** |
| 449 | ** pm8001_ctl_fatal_log_show - fatal error logging |
| 450 | ** @cdev:pointer to embedded class device |
| 451 | ** @buf: the buffer returned |
| 452 | ** |
| 453 | ** A sysfs 'read-only' shost attribute. |
| 454 | **/ |
| 455 | |
| 456 | static ssize_t pm8001_ctl_fatal_log_show(struct device *cdev, |
| 457 | struct device_attribute *attr, char *buf) |
| 458 | { |
Viswas G | cf37006 | 2013-12-10 10:31:38 +0530 | [diff] [blame] | 459 | ssize_t count; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 460 | |
| 461 | count = pm80xx_get_fatal_dump(cdev, attr, buf); |
| 462 | return count; |
| 463 | } |
| 464 | |
| 465 | static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL); |
| 466 | |
| 467 | |
| 468 | /** |
| 469 | ** pm8001_ctl_gsm_log_show - gsm dump collection |
| 470 | ** @cdev:pointer to embedded class device |
| 471 | ** @buf: the buffer returned |
| 472 | **A sysfs 'read-only' shost attribute. |
| 473 | **/ |
| 474 | static ssize_t pm8001_ctl_gsm_log_show(struct device *cdev, |
| 475 | struct device_attribute *attr, char *buf) |
| 476 | { |
Viswas G | cf37006 | 2013-12-10 10:31:38 +0530 | [diff] [blame] | 477 | ssize_t count; |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 478 | |
| 479 | count = pm8001_get_gsm_dump(cdev, SYSFS_OFFSET, buf); |
| 480 | return count; |
| 481 | } |
| 482 | |
| 483 | static DEVICE_ATTR(gsm_log, S_IRUGO, pm8001_ctl_gsm_log_show, NULL); |
| 484 | |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 485 | #define FLASH_CMD_NONE 0x00 |
| 486 | #define FLASH_CMD_UPDATE 0x01 |
| 487 | #define FLASH_CMD_SET_NVMD 0x02 |
| 488 | |
| 489 | struct flash_command { |
| 490 | u8 command[8]; |
| 491 | int code; |
| 492 | }; |
| 493 | |
| 494 | static struct flash_command flash_command_table[] = |
| 495 | { |
| 496 | {"set_nvmd", FLASH_CMD_SET_NVMD}, |
| 497 | {"update", FLASH_CMD_UPDATE}, |
| 498 | {"", FLASH_CMD_NONE} /* Last entry should be NULL. */ |
| 499 | }; |
| 500 | |
| 501 | struct error_fw { |
| 502 | char *reason; |
| 503 | int err_code; |
| 504 | }; |
| 505 | |
| 506 | static struct error_fw flash_error_table[] = |
| 507 | { |
| 508 | {"Failed to open fw image file", FAIL_OPEN_BIOS_FILE}, |
| 509 | {"image header mismatch", FLASH_UPDATE_HDR_ERR}, |
| 510 | {"image offset mismatch", FLASH_UPDATE_OFFSET_ERR}, |
| 511 | {"image CRC Error", FLASH_UPDATE_CRC_ERR}, |
| 512 | {"image length Error.", FLASH_UPDATE_LENGTH_ERR}, |
| 513 | {"Failed to program flash chip", FLASH_UPDATE_HW_ERR}, |
| 514 | {"Flash chip not supported.", FLASH_UPDATE_DNLD_NOT_SUPPORTED}, |
| 515 | {"Flash update disabled.", FLASH_UPDATE_DISABLED}, |
| 516 | {"Flash in progress", FLASH_IN_PROGRESS}, |
| 517 | {"Image file size Error", FAIL_FILE_SIZE}, |
| 518 | {"Input parameter error", FAIL_PARAMETERS}, |
| 519 | {"Out of memory", FAIL_OUT_MEMORY}, |
| 520 | {"OK", 0} /* Last entry err_code = 0. */ |
| 521 | }; |
| 522 | |
| 523 | static int pm8001_set_nvmd(struct pm8001_hba_info *pm8001_ha) |
| 524 | { |
| 525 | struct pm8001_ioctl_payload *payload; |
| 526 | DECLARE_COMPLETION_ONSTACK(completion); |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 527 | u8 *ioctlbuffer; |
| 528 | u32 ret; |
| 529 | u32 length = 1024 * 5 + sizeof(*payload) - 1; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 530 | |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 531 | if (pm8001_ha->fw_image->size > 4096) { |
| 532 | pm8001_ha->fw_status = FAIL_FILE_SIZE; |
| 533 | return -EFAULT; |
| 534 | } |
| 535 | |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 536 | ioctlbuffer = kzalloc(length, GFP_KERNEL); |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 537 | if (!ioctlbuffer) { |
| 538 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 539 | return -ENOMEM; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 540 | } |
| 541 | payload = (struct pm8001_ioctl_payload *)ioctlbuffer; |
Sakthivel K | 1c75a67 | 2013-03-19 18:06:40 +0530 | [diff] [blame] | 542 | memcpy((u8 *)&payload->func_specific, (u8 *)pm8001_ha->fw_image->data, |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 543 | pm8001_ha->fw_image->size); |
| 544 | payload->length = pm8001_ha->fw_image->size; |
| 545 | payload->id = 0; |
Sakthivel K | 1c75a67 | 2013-03-19 18:06:40 +0530 | [diff] [blame] | 546 | payload->minor_function = 0x1; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 547 | pm8001_ha->nvmd_completion = &completion; |
| 548 | ret = PM8001_CHIP_DISP->set_nvmd_req(pm8001_ha, payload); |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 549 | if (ret) { |
| 550 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; |
| 551 | goto out; |
| 552 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 553 | wait_for_completion(&completion); |
| 554 | out: |
| 555 | kfree(ioctlbuffer); |
| 556 | return ret; |
| 557 | } |
| 558 | |
| 559 | static int pm8001_update_flash(struct pm8001_hba_info *pm8001_ha) |
| 560 | { |
| 561 | struct pm8001_ioctl_payload *payload; |
| 562 | DECLARE_COMPLETION_ONSTACK(completion); |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 563 | u8 *ioctlbuffer; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 564 | struct fw_control_info *fwControl; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 565 | u32 partitionSize, partitionSizeTmp; |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 566 | u32 loopNumber, loopcount; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 567 | struct pm8001_fw_image_header *image_hdr; |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 568 | u32 sizeRead = 0; |
| 569 | u32 ret = 0; |
| 570 | u32 length = 1024 * 16 + sizeof(*payload) - 1; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 571 | |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 572 | if (pm8001_ha->fw_image->size < 28) { |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 573 | pm8001_ha->fw_status = FAIL_FILE_SIZE; |
| 574 | return -EFAULT; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 575 | } |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 576 | ioctlbuffer = kzalloc(length, GFP_KERNEL); |
| 577 | if (!ioctlbuffer) { |
| 578 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; |
| 579 | return -ENOMEM; |
| 580 | } |
| 581 | image_hdr = (struct pm8001_fw_image_header *)pm8001_ha->fw_image->data; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 582 | while (sizeRead < pm8001_ha->fw_image->size) { |
| 583 | partitionSizeTmp = |
| 584 | *(u32 *)((u8 *)&image_hdr->image_length + sizeRead); |
| 585 | partitionSize = be32_to_cpu(partitionSizeTmp); |
Tomas Henzl | 5bd355e | 2014-07-30 16:40:51 +0200 | [diff] [blame] | 586 | loopcount = DIV_ROUND_UP(partitionSize + HEADER_LEN, |
| 587 | IOCTL_BUF_SIZE); |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 588 | for (loopNumber = 0; loopNumber < loopcount; loopNumber++) { |
| 589 | payload = (struct pm8001_ioctl_payload *)ioctlbuffer; |
| 590 | payload->length = 1024*16; |
| 591 | payload->id = 0; |
| 592 | fwControl = |
Sakthivel K | 1c75a67 | 2013-03-19 18:06:40 +0530 | [diff] [blame] | 593 | (struct fw_control_info *)&payload->func_specific; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 594 | fwControl->len = IOCTL_BUF_SIZE; /* IN */ |
| 595 | fwControl->size = partitionSize + HEADER_LEN;/* IN */ |
| 596 | fwControl->retcode = 0;/* OUT */ |
| 597 | fwControl->offset = loopNumber * IOCTL_BUF_SIZE;/*OUT */ |
| 598 | |
| 599 | /* for the last chunk of data in case file size is not even with |
| 600 | 4k, load only the rest*/ |
| 601 | if (((loopcount-loopNumber) == 1) && |
| 602 | ((partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE)) { |
| 603 | fwControl->len = |
| 604 | (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE; |
| 605 | memcpy((u8 *)fwControl->buffer, |
| 606 | (u8 *)pm8001_ha->fw_image->data + sizeRead, |
| 607 | (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE); |
| 608 | sizeRead += |
| 609 | (partitionSize + HEADER_LEN) % IOCTL_BUF_SIZE; |
| 610 | } else { |
| 611 | memcpy((u8 *)fwControl->buffer, |
| 612 | (u8 *)pm8001_ha->fw_image->data + sizeRead, |
| 613 | IOCTL_BUF_SIZE); |
| 614 | sizeRead += IOCTL_BUF_SIZE; |
| 615 | } |
| 616 | |
| 617 | pm8001_ha->nvmd_completion = &completion; |
| 618 | ret = PM8001_CHIP_DISP->fw_flash_update_req(pm8001_ha, payload); |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 619 | if (ret) { |
| 620 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; |
| 621 | goto out; |
| 622 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 623 | wait_for_completion(&completion); |
Tomas Henzl | 31d05e5 | 2014-07-07 17:19:59 +0200 | [diff] [blame] | 624 | if (fwControl->retcode > FLASH_UPDATE_IN_PROGRESS) { |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 625 | pm8001_ha->fw_status = fwControl->retcode; |
| 626 | ret = -EFAULT; |
| 627 | goto out; |
| 628 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 629 | } |
| 630 | } |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 631 | out: |
| 632 | kfree(ioctlbuffer); |
| 633 | return ret; |
| 634 | } |
| 635 | static ssize_t pm8001_store_update_fw(struct device *cdev, |
| 636 | struct device_attribute *attr, |
| 637 | const char *buf, size_t count) |
| 638 | { |
| 639 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 640 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 641 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 642 | char *cmd_ptr, *filename_ptr; |
| 643 | int res, i; |
| 644 | int flash_command = FLASH_CMD_NONE; |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 645 | int ret; |
| 646 | |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 647 | if (!capable(CAP_SYS_ADMIN)) |
| 648 | return -EACCES; |
| 649 | |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 650 | /* this test protects us from running two flash processes at once, |
| 651 | * so we should start with this test */ |
| 652 | if (pm8001_ha->fw_status == FLASH_IN_PROGRESS) |
| 653 | return -EINPROGRESS; |
| 654 | pm8001_ha->fw_status = FLASH_IN_PROGRESS; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 655 | |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 656 | cmd_ptr = kzalloc(count*2, GFP_KERNEL); |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 657 | if (!cmd_ptr) { |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 658 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; |
| 659 | return -ENOMEM; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | filename_ptr = cmd_ptr + count; |
| 663 | res = sscanf(buf, "%s %s", cmd_ptr, filename_ptr); |
| 664 | if (res != 2) { |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 665 | pm8001_ha->fw_status = FAIL_PARAMETERS; |
| 666 | ret = -EINVAL; |
| 667 | goto out; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | for (i = 0; flash_command_table[i].code != FLASH_CMD_NONE; i++) { |
| 671 | if (!memcmp(flash_command_table[i].command, |
| 672 | cmd_ptr, strlen(cmd_ptr))) { |
| 673 | flash_command = flash_command_table[i].code; |
| 674 | break; |
| 675 | } |
| 676 | } |
| 677 | if (flash_command == FLASH_CMD_NONE) { |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 678 | pm8001_ha->fw_status = FAIL_PARAMETERS; |
| 679 | ret = -EINVAL; |
| 680 | goto out; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 681 | } |
| 682 | |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 683 | ret = request_firmware(&pm8001_ha->fw_image, |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 684 | filename_ptr, |
| 685 | pm8001_ha->dev); |
| 686 | |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 687 | if (ret) { |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 688 | PM8001_FAIL_DBG(pm8001_ha, |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 689 | pm8001_printk( |
| 690 | "Failed to load firmware image file %s, error %d\n", |
| 691 | filename_ptr, ret)); |
| 692 | pm8001_ha->fw_status = FAIL_OPEN_BIOS_FILE; |
| 693 | goto out; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 694 | } |
| 695 | |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 696 | if (FLASH_CMD_UPDATE == flash_command) |
| 697 | ret = pm8001_update_flash(pm8001_ha); |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 698 | else |
Tomas Henzl | 6f8f31c | 2014-07-30 18:42:22 +0530 | [diff] [blame] | 699 | ret = pm8001_set_nvmd(pm8001_ha); |
| 700 | |
| 701 | release_firmware(pm8001_ha->fw_image); |
| 702 | out: |
| 703 | kfree(cmd_ptr); |
| 704 | |
| 705 | if (ret) |
| 706 | return ret; |
| 707 | |
| 708 | pm8001_ha->fw_status = FLASH_OK; |
| 709 | return count; |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | static ssize_t pm8001_show_update_fw(struct device *cdev, |
| 713 | struct device_attribute *attr, char *buf) |
| 714 | { |
| 715 | int i; |
| 716 | struct Scsi_Host *shost = class_to_shost(cdev); |
| 717 | struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); |
| 718 | struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; |
| 719 | |
| 720 | for (i = 0; flash_error_table[i].err_code != 0; i++) { |
| 721 | if (flash_error_table[i].err_code == pm8001_ha->fw_status) |
| 722 | break; |
| 723 | } |
| 724 | if (pm8001_ha->fw_status != FLASH_IN_PROGRESS) |
| 725 | pm8001_ha->fw_status = FLASH_OK; |
| 726 | |
| 727 | return snprintf(buf, PAGE_SIZE, "status=%x %s\n", |
| 728 | flash_error_table[i].err_code, |
| 729 | flash_error_table[i].reason); |
| 730 | } |
| 731 | |
Rusty Russell | 332e2b4 | 2014-05-14 10:33:48 +0930 | [diff] [blame] | 732 | static DEVICE_ATTR(update_fw, S_IRUGO|S_IWUSR|S_IWGRP, |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 733 | pm8001_show_update_fw, pm8001_store_update_fw); |
| 734 | struct device_attribute *pm8001_host_attrs[] = { |
| 735 | &dev_attr_interface_rev, |
| 736 | &dev_attr_fw_version, |
| 737 | &dev_attr_update_fw, |
| 738 | &dev_attr_aap_log, |
| 739 | &dev_attr_iop_log, |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 740 | &dev_attr_fatal_log, |
| 741 | &dev_attr_gsm_log, |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 742 | &dev_attr_max_out_io, |
| 743 | &dev_attr_max_devices, |
| 744 | &dev_attr_max_sg_list, |
| 745 | &dev_attr_sas_spec_support, |
| 746 | &dev_attr_logging_level, |
| 747 | &dev_attr_host_sas_address, |
Anand Kumar Santhanam | 966fdcf | 2013-09-18 12:54:41 +0530 | [diff] [blame] | 748 | &dev_attr_bios_version, |
Anand Kumar Santhanam | d078b51 | 2013-09-04 12:57:00 +0530 | [diff] [blame] | 749 | &dev_attr_ib_log, |
| 750 | &dev_attr_ob_log, |
jack wang | dbf9bfe | 2009-10-14 16:19:21 +0800 | [diff] [blame] | 751 | NULL, |
| 752 | }; |
| 753 | |