Lines Matching refs:cmd
69 u8 cmd; member
113 struct smu_cmd *cmd; in smu_start_cmd() local
119 cmd = list_entry(smu->cmd_list.next, struct smu_cmd, link); in smu_start_cmd()
120 smu->cmd_cur = cmd; in smu_start_cmd()
121 list_del(&cmd->link); in smu_start_cmd()
123 DPRINTK("SMU: starting cmd %x, %d bytes data\n", cmd->cmd, in smu_start_cmd()
124 cmd->data_len); in smu_start_cmd()
126 ((u8 *)cmd->data_buf)[0], ((u8 *)cmd->data_buf)[1], in smu_start_cmd()
127 ((u8 *)cmd->data_buf)[2], ((u8 *)cmd->data_buf)[3], in smu_start_cmd()
128 ((u8 *)cmd->data_buf)[4], ((u8 *)cmd->data_buf)[5], in smu_start_cmd()
129 ((u8 *)cmd->data_buf)[6], ((u8 *)cmd->data_buf)[7]); in smu_start_cmd()
132 smu->cmd_buf->cmd = cmd->cmd; in smu_start_cmd()
133 smu->cmd_buf->length = cmd->data_len; in smu_start_cmd()
134 memcpy(smu->cmd_buf->data, cmd->data_buf, cmd->data_len); in smu_start_cmd()
168 struct smu_cmd *cmd; in smu_db_intr() local
169 void (*done)(struct smu_cmd *cmd, void *misc) = NULL; in smu_db_intr()
185 cmd = smu->cmd_cur; in smu_db_intr()
187 if (cmd == NULL) in smu_db_intr()
204 ack = (~cmd->cmd) & 0xff; in smu_db_intr()
205 if (ack != smu->cmd_buf->cmd) { in smu_db_intr()
207 ack, smu->cmd_buf->cmd); in smu_db_intr()
212 if (reply_len > cmd->reply_len) { in smu_db_intr()
215 reply_len, cmd->reply_len); in smu_db_intr()
216 reply_len = cmd->reply_len; in smu_db_intr()
218 cmd->reply_len = reply_len; in smu_db_intr()
219 if (cmd->reply_buf && reply_len) in smu_db_intr()
220 memcpy(cmd->reply_buf, smu->cmd_buf->data, reply_len); in smu_db_intr()
226 done = cmd->done; in smu_db_intr()
227 misc = cmd->misc; in smu_db_intr()
229 cmd->status = rc; in smu_db_intr()
241 done(cmd, misc); in smu_db_intr()
267 int smu_queue_cmd(struct smu_cmd *cmd) in smu_queue_cmd() argument
273 if (cmd->data_len > SMU_MAX_DATA || in smu_queue_cmd()
274 cmd->reply_len > SMU_MAX_DATA) in smu_queue_cmd()
277 cmd->status = 1; in smu_queue_cmd()
279 list_add_tail(&cmd->link, &smu->cmd_list); in smu_queue_cmd()
286 smu_spinwait_cmd(cmd); in smu_queue_cmd()
295 void (*done)(struct smu_cmd *cmd, void *misc), in smu_queue_simple() argument
298 struct smu_cmd *cmd = &scmd->cmd; in smu_queue_simple() local
306 cmd->cmd = command; in smu_queue_simple()
307 cmd->data_len = data_len; in smu_queue_simple()
308 cmd->data_buf = scmd->buffer; in smu_queue_simple()
309 cmd->reply_len = sizeof(scmd->buffer); in smu_queue_simple()
310 cmd->reply_buf = scmd->buffer; in smu_queue_simple()
311 cmd->done = done; in smu_queue_simple()
312 cmd->misc = misc; in smu_queue_simple()
319 return smu_queue_cmd(cmd); in smu_queue_simple()
338 void smu_done_complete(struct smu_cmd *cmd, void *misc) in smu_done_complete() argument
347 void smu_spinwait_cmd(struct smu_cmd *cmd) in smu_spinwait_cmd() argument
349 while(cmd->status == 1) in smu_spinwait_cmd()
371 cmd_buf->cmd = 0x8e; in smu_fill_set_rtc_cmd()
386 struct smu_simple_cmd cmd; in smu_get_rtc_time() local
393 rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 1, NULL, NULL, in smu_get_rtc_time()
397 smu_spinwait_simple(&cmd); in smu_get_rtc_time()
399 time->tm_sec = bcd2hex(cmd.buffer[0]); in smu_get_rtc_time()
400 time->tm_min = bcd2hex(cmd.buffer[1]); in smu_get_rtc_time()
401 time->tm_hour = bcd2hex(cmd.buffer[2]); in smu_get_rtc_time()
402 time->tm_wday = bcd2hex(cmd.buffer[3]); in smu_get_rtc_time()
403 time->tm_mday = bcd2hex(cmd.buffer[4]); in smu_get_rtc_time()
404 time->tm_mon = bcd2hex(cmd.buffer[5]) - 1; in smu_get_rtc_time()
405 time->tm_year = bcd2hex(cmd.buffer[6]) + 100; in smu_get_rtc_time()
413 struct smu_simple_cmd cmd; in smu_set_rtc_time() local
419 rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 8, NULL, NULL, in smu_set_rtc_time()
430 smu_spinwait_simple(&cmd); in smu_set_rtc_time()
438 struct smu_simple_cmd cmd; in smu_shutdown() local
443 if (smu_queue_simple(&cmd, SMU_CMD_POWER_COMMAND, 9, NULL, NULL, in smu_shutdown()
446 smu_spinwait_simple(&cmd); in smu_shutdown()
454 struct smu_simple_cmd cmd; in smu_restart() local
459 if (smu_queue_simple(&cmd, SMU_CMD_POWER_COMMAND, 8, NULL, NULL, in smu_restart()
462 smu_spinwait_simple(&cmd); in smu_restart()
710 static void smu_i2c_complete_command(struct smu_i2c_cmd *cmd, int fail) in smu_i2c_complete_command() argument
712 void (*done)(struct smu_i2c_cmd *cmd, void *misc) = cmd->done; in smu_i2c_complete_command()
713 void *misc = cmd->misc; in smu_i2c_complete_command()
717 if (!fail && cmd->read) { in smu_i2c_complete_command()
718 if (cmd->pdata[0] < 1) in smu_i2c_complete_command()
721 memcpy(cmd->info.data, &cmd->pdata[1], in smu_i2c_complete_command()
722 cmd->info.datalen); in smu_i2c_complete_command()
734 cmd->status = fail ? -EIO : 0; in smu_i2c_complete_command()
744 list_del(&cmd->link); in smu_i2c_complete_command()
747 list_add_tail(&cmd->scmd.link, &smu->cmd_list); in smu_i2c_complete_command()
755 done(cmd, misc); in smu_i2c_complete_command()
762 struct smu_i2c_cmd *cmd = smu->cmd_i2c_cur; in smu_i2c_retry() local
767 cmd->pdata[0] = 0xff; in smu_i2c_retry()
768 cmd->scmd.reply_len = sizeof(cmd->pdata); in smu_i2c_retry()
769 smu_queue_cmd(&cmd->scmd); in smu_i2c_retry()
775 struct smu_i2c_cmd *cmd = misc; in smu_i2c_low_completion() local
779 cmd->stage, scmd->status, cmd->pdata[0], scmd->reply_len); in smu_i2c_low_completion()
784 else if (cmd->read) { in smu_i2c_low_completion()
785 if (cmd->stage == 0) in smu_i2c_low_completion()
786 fail = cmd->pdata[0] != 0; in smu_i2c_low_completion()
788 fail = cmd->pdata[0] >= 0x80; in smu_i2c_low_completion()
790 fail = cmd->pdata[0] != 0; in smu_i2c_low_completion()
795 if (fail && --cmd->retries > 0) { in smu_i2c_low_completion()
797 BUG_ON(cmd != smu->cmd_i2c_cur); in smu_i2c_low_completion()
808 if (fail || cmd->stage != 0) { in smu_i2c_low_completion()
809 smu_i2c_complete_command(cmd, fail); in smu_i2c_low_completion()
816 scmd->reply_buf = cmd->pdata; in smu_i2c_low_completion()
817 scmd->reply_len = sizeof(cmd->pdata); in smu_i2c_low_completion()
818 scmd->data_buf = cmd->pdata; in smu_i2c_low_completion()
820 cmd->pdata[0] = 0; in smu_i2c_low_completion()
821 cmd->stage = 1; in smu_i2c_low_completion()
822 cmd->retries = 20; in smu_i2c_low_completion()
827 int smu_queue_i2c(struct smu_i2c_cmd *cmd) in smu_queue_i2c() argument
835 cmd->scmd.cmd = SMU_CMD_I2C_COMMAND; in smu_queue_i2c()
836 cmd->scmd.done = smu_i2c_low_completion; in smu_queue_i2c()
837 cmd->scmd.misc = cmd; in smu_queue_i2c()
838 cmd->scmd.reply_buf = cmd->pdata; in smu_queue_i2c()
839 cmd->scmd.reply_len = sizeof(cmd->pdata); in smu_queue_i2c()
840 cmd->scmd.data_buf = (u8 *)(char *)&cmd->info; in smu_queue_i2c()
841 cmd->scmd.status = 1; in smu_queue_i2c()
842 cmd->stage = 0; in smu_queue_i2c()
843 cmd->pdata[0] = 0xff; in smu_queue_i2c()
844 cmd->retries = 20; in smu_queue_i2c()
845 cmd->status = 1; in smu_queue_i2c()
850 cmd->info.caddr = cmd->info.devaddr; in smu_queue_i2c()
851 cmd->read = cmd->info.devaddr & 0x01; in smu_queue_i2c()
852 switch(cmd->info.type) { in smu_queue_i2c()
854 memset(&cmd->info.sublen, 0, 4); in smu_queue_i2c()
857 cmd->info.devaddr &= 0xfe; in smu_queue_i2c()
859 if (cmd->info.sublen > 3) in smu_queue_i2c()
868 if (cmd->read) { in smu_queue_i2c()
869 if (cmd->info.datalen > SMU_I2C_READ_MAX) in smu_queue_i2c()
871 memset(cmd->info.data, 0xff, cmd->info.datalen); in smu_queue_i2c()
872 cmd->scmd.data_len = 9; in smu_queue_i2c()
874 if (cmd->info.datalen > SMU_I2C_WRITE_MAX) in smu_queue_i2c()
876 cmd->scmd.data_len = 9 + cmd->info.datalen; in smu_queue_i2c()
881 cmd->read ? "read" : "write", cmd->info.datalen, in smu_queue_i2c()
882 cmd->info.bus, cmd->info.caddr, in smu_queue_i2c()
883 cmd->info.subaddr[0], cmd->info.type); in smu_queue_i2c()
891 smu->cmd_i2c_cur = cmd; in smu_queue_i2c()
892 list_add_tail(&cmd->scmd.link, &smu->cmd_list); in smu_queue_i2c()
896 list_add_tail(&cmd->link, &smu->cmd_i2c_list); in smu_queue_i2c()
910 struct smu_cmd cmd; in smu_read_datablock() local
922 cmd.cmd = SMU_CMD_MISC_ee_COMMAND; in smu_read_datablock()
923 cmd.data_len = 7; in smu_read_datablock()
924 cmd.data_buf = params; in smu_read_datablock()
925 cmd.reply_len = chunk; in smu_read_datablock()
926 cmd.reply_buf = dest; in smu_read_datablock()
927 cmd.done = smu_done_complete; in smu_read_datablock()
928 cmd.misc = ∁ in smu_read_datablock()
934 rc = smu_queue_cmd(&cmd); in smu_read_datablock()
938 if (cmd.status != 0) in smu_read_datablock()
940 if (cmd.reply_len != clen) { in smu_read_datablock()
943 cmd.reply_len, clen); in smu_read_datablock()
956 struct smu_simple_cmd cmd; in smu_create_sdb_partition() local
963 smu_queue_simple(&cmd, SMU_CMD_PARTITION_COMMAND, 2, in smu_create_sdb_partition()
968 cmd.cmd.status, cmd.cmd.reply_len); in smu_create_sdb_partition()
971 if (cmd.cmd.status != 0 || cmd.cmd.reply_len != 6) in smu_create_sdb_partition()
975 addr = *((u16 *)cmd.buffer); in smu_create_sdb_partition()
976 len = cmd.buffer[3] << 2; in smu_create_sdb_partition()
1078 struct smu_cmd cmd; member
1108 static void smu_user_cmd_done(struct smu_cmd *cmd, void *misc) in smu_user_cmd_done() argument
1133 part = __smu_get_sdb_partition(hdr.cmd, NULL, 1); in smu_write()
1152 pp->cmd.status = 1; in smu_write()
1160 pp->cmd.cmd = hdr.cmd; in smu_write()
1161 pp->cmd.data_len = hdr.data_len; in smu_write()
1162 pp->cmd.reply_len = SMU_MAX_DATA; in smu_write()
1163 pp->cmd.data_buf = pp->buffer; in smu_write()
1164 pp->cmd.reply_buf = pp->buffer; in smu_write()
1165 pp->cmd.done = smu_user_cmd_done; in smu_write()
1166 pp->cmd.misc = pp; in smu_write()
1167 rc = smu_queue_cmd(&pp->cmd); in smu_write()
1187 if (pp->cmd.status == 1) { in smu_read_command()
1196 if (pp->cmd.status != 1) in smu_read_command()
1211 if (pp->cmd.status != 0) in smu_read_command()
1212 pp->cmd.reply_len = 0; in smu_read_command()
1213 size = sizeof(hdr) + pp->cmd.reply_len; in smu_read_command()
1217 hdr.status = pp->cmd.status; in smu_read_command()
1218 hdr.reply_len = pp->cmd.reply_len; in smu_read_command()
1265 if (pp->busy && pp->cmd.status != 1) in smu_fpoll()
1291 if (busy && pp->cmd.status == 1) { in smu_release()
1297 if (pp->cmd.status != 1) in smu_release()