30 #include <linux/device.h>
66 result =
i1480_cmd(i1480,
"MPI-WRITE",
sizeof(*cmd) + size,
sizeof(*reply));
70 dev_err(i1480->
dev,
"MPI-WRITE: command execution failed: %d\n",
100 int i1480_mpi_read(
struct i1480 *i1480,
u8 *data,
u16 srcaddr,
size_t size)
115 for (cnt = 0; cnt <
size; cnt++) {
121 result =
i1480_cmd(i1480,
"MPI-READ",
sizeof(*cmd) + 2*size,
122 sizeof(*reply) + 3*size);
126 dev_err(i1480->
dev,
"MPI-READ: command execution failed: %d\n",
130 for (cnt = 0; cnt <
size; cnt++) {
131 if (reply->data[cnt].
page != (srcaddr + cnt) >> 8)
132 dev_err(i1480->
dev,
"MPI-READ: page inconsistency at "
133 "index %u: expected 0x%02x, got 0x%02x\n", cnt,
134 (srcaddr + cnt) >> 8, reply->data[cnt].
page);
135 if (reply->data[cnt].
offset != ((srcaddr + cnt) & 0x00ff))
136 dev_err(i1480->
dev,
"MPI-READ: offset inconsistency at "
137 "index %u: expected 0x%02x, got 0x%02x\n", cnt,
138 (srcaddr + cnt) & 0x00ff,
166 const char *data_itr, *data_top;
167 const size_t MAX_BLK_SIZE = 480;
175 for (data_itr = fw->
data, data_top = data_itr + fw->
size;
176 data_itr < data_top; data_itr += MAX_BLK_SIZE) {
177 data_size =
min(MAX_BLK_SIZE, (
size_t) (data_top - data_itr));
178 result = i1480_mpi_write(i1480, data_itr, data_size);
180 goto error_mpi_write;
183 result = i1480_mpi_read(i1480, &phy_stat, 0x0006, 1);
185 dev_err(i1480->
dev,
"PHY: can't get status: %d\n", result);
186 goto error_mpi_status;
190 dev_info(i1480->
dev,
"error, PHY not ready: %u\n", phy_stat);
191 goto error_phy_status;
199 dev_err(i1480->
dev,
"PHY fw '%s': failed to upload (%d), "
200 "power cycle device\n", i1480->
phy_fw_name, result);