Lines Matching refs:cmd

69 	u8 cmd;  member
114 struct smu_cmd *cmd; in smu_start_cmd() local
120 cmd = list_entry(smu->cmd_list.next, struct smu_cmd, link); in smu_start_cmd()
121 smu->cmd_cur = cmd; in smu_start_cmd()
122 list_del(&cmd->link); in smu_start_cmd()
124 DPRINTK("SMU: starting cmd %x, %d bytes data\n", cmd->cmd, in smu_start_cmd()
125 cmd->data_len); in smu_start_cmd()
126 DPRINTK("SMU: data buffer: %8ph\n", cmd->data_buf); in smu_start_cmd()
129 smu->cmd_buf->cmd = cmd->cmd; in smu_start_cmd()
130 smu->cmd_buf->length = cmd->data_len; in smu_start_cmd()
131 memcpy(smu->cmd_buf->data, cmd->data_buf, cmd->data_len); in smu_start_cmd()
165 struct smu_cmd *cmd; in smu_db_intr() local
166 void (*done)(struct smu_cmd *cmd, void *misc) = NULL; in smu_db_intr()
182 cmd = smu->cmd_cur; in smu_db_intr()
184 if (cmd == NULL) in smu_db_intr()
201 ack = (~cmd->cmd) & 0xff; in smu_db_intr()
202 if (ack != smu->cmd_buf->cmd) { in smu_db_intr()
204 ack, smu->cmd_buf->cmd); in smu_db_intr()
209 if (reply_len > cmd->reply_len) { in smu_db_intr()
212 reply_len, cmd->reply_len); in smu_db_intr()
213 reply_len = cmd->reply_len; in smu_db_intr()
215 cmd->reply_len = reply_len; in smu_db_intr()
216 if (cmd->reply_buf && reply_len) in smu_db_intr()
217 memcpy(cmd->reply_buf, smu->cmd_buf->data, reply_len); in smu_db_intr()
223 done = cmd->done; in smu_db_intr()
224 misc = cmd->misc; in smu_db_intr()
226 cmd->status = rc; in smu_db_intr()
238 done(cmd, misc); in smu_db_intr()
264 int smu_queue_cmd(struct smu_cmd *cmd) in smu_queue_cmd() argument
270 if (cmd->data_len > SMU_MAX_DATA || in smu_queue_cmd()
271 cmd->reply_len > SMU_MAX_DATA) in smu_queue_cmd()
274 cmd->status = 1; in smu_queue_cmd()
276 list_add_tail(&cmd->link, &smu->cmd_list); in smu_queue_cmd()
283 smu_spinwait_cmd(cmd); in smu_queue_cmd()
292 void (*done)(struct smu_cmd *cmd, void *misc), in smu_queue_simple() argument
295 struct smu_cmd *cmd = &scmd->cmd; in smu_queue_simple() local
303 cmd->cmd = command; in smu_queue_simple()
304 cmd->data_len = data_len; in smu_queue_simple()
305 cmd->data_buf = scmd->buffer; in smu_queue_simple()
306 cmd->reply_len = sizeof(scmd->buffer); in smu_queue_simple()
307 cmd->reply_buf = scmd->buffer; in smu_queue_simple()
308 cmd->done = done; in smu_queue_simple()
309 cmd->misc = misc; in smu_queue_simple()
316 return smu_queue_cmd(cmd); in smu_queue_simple()
335 void smu_done_complete(struct smu_cmd *cmd, void *misc) in smu_done_complete() argument
344 void smu_spinwait_cmd(struct smu_cmd *cmd) in smu_spinwait_cmd() argument
346 while(cmd->status == 1) in smu_spinwait_cmd()
368 cmd_buf->cmd = 0x8e; in smu_fill_set_rtc_cmd()
383 struct smu_simple_cmd cmd; in smu_get_rtc_time() local
390 rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 1, NULL, NULL, in smu_get_rtc_time()
394 smu_spinwait_simple(&cmd); in smu_get_rtc_time()
396 time->tm_sec = bcd2hex(cmd.buffer[0]); in smu_get_rtc_time()
397 time->tm_min = bcd2hex(cmd.buffer[1]); in smu_get_rtc_time()
398 time->tm_hour = bcd2hex(cmd.buffer[2]); in smu_get_rtc_time()
399 time->tm_wday = bcd2hex(cmd.buffer[3]); in smu_get_rtc_time()
400 time->tm_mday = bcd2hex(cmd.buffer[4]); in smu_get_rtc_time()
401 time->tm_mon = bcd2hex(cmd.buffer[5]) - 1; in smu_get_rtc_time()
402 time->tm_year = bcd2hex(cmd.buffer[6]) + 100; in smu_get_rtc_time()
410 struct smu_simple_cmd cmd; in smu_set_rtc_time() local
416 rc = smu_queue_simple(&cmd, SMU_CMD_RTC_COMMAND, 8, NULL, NULL, in smu_set_rtc_time()
427 smu_spinwait_simple(&cmd); in smu_set_rtc_time()
435 struct smu_simple_cmd cmd; in smu_shutdown() local
440 if (smu_queue_simple(&cmd, SMU_CMD_POWER_COMMAND, 9, NULL, NULL, in smu_shutdown()
443 smu_spinwait_simple(&cmd); in smu_shutdown()
451 struct smu_simple_cmd cmd; in smu_restart() local
456 if (smu_queue_simple(&cmd, SMU_CMD_POWER_COMMAND, 8, NULL, NULL, in smu_restart()
459 smu_spinwait_simple(&cmd); in smu_restart()
706 static void smu_i2c_complete_command(struct smu_i2c_cmd *cmd, int fail) in smu_i2c_complete_command() argument
708 void (*done)(struct smu_i2c_cmd *cmd, void *misc) = cmd->done; in smu_i2c_complete_command()
709 void *misc = cmd->misc; in smu_i2c_complete_command()
713 if (!fail && cmd->read) { in smu_i2c_complete_command()
714 if (cmd->pdata[0] < 1) in smu_i2c_complete_command()
717 memcpy(cmd->info.data, &cmd->pdata[1], in smu_i2c_complete_command()
718 cmd->info.datalen); in smu_i2c_complete_command()
730 cmd->status = fail ? -EIO : 0; in smu_i2c_complete_command()
740 list_del(&cmd->link); in smu_i2c_complete_command()
743 list_add_tail(&cmd->scmd.link, &smu->cmd_list); in smu_i2c_complete_command()
751 done(cmd, misc); in smu_i2c_complete_command()
758 struct smu_i2c_cmd *cmd = smu->cmd_i2c_cur; in smu_i2c_retry() local
763 cmd->pdata[0] = 0xff; in smu_i2c_retry()
764 cmd->scmd.reply_len = sizeof(cmd->pdata); in smu_i2c_retry()
765 smu_queue_cmd(&cmd->scmd); in smu_i2c_retry()
771 struct smu_i2c_cmd *cmd = misc; in smu_i2c_low_completion() local
775 cmd->stage, scmd->status, cmd->pdata[0], scmd->reply_len); in smu_i2c_low_completion()
780 else if (cmd->read) { in smu_i2c_low_completion()
781 if (cmd->stage == 0) in smu_i2c_low_completion()
782 fail = cmd->pdata[0] != 0; in smu_i2c_low_completion()
784 fail = cmd->pdata[0] >= 0x80; in smu_i2c_low_completion()
786 fail = cmd->pdata[0] != 0; in smu_i2c_low_completion()
791 if (fail && --cmd->retries > 0) { in smu_i2c_low_completion()
793 BUG_ON(cmd != smu->cmd_i2c_cur); in smu_i2c_low_completion()
804 if (fail || cmd->stage != 0) { in smu_i2c_low_completion()
805 smu_i2c_complete_command(cmd, fail); in smu_i2c_low_completion()
812 scmd->reply_buf = cmd->pdata; in smu_i2c_low_completion()
813 scmd->reply_len = sizeof(cmd->pdata); in smu_i2c_low_completion()
814 scmd->data_buf = cmd->pdata; in smu_i2c_low_completion()
816 cmd->pdata[0] = 0; in smu_i2c_low_completion()
817 cmd->stage = 1; in smu_i2c_low_completion()
818 cmd->retries = 20; in smu_i2c_low_completion()
823 int smu_queue_i2c(struct smu_i2c_cmd *cmd) in smu_queue_i2c() argument
831 cmd->scmd.cmd = SMU_CMD_I2C_COMMAND; in smu_queue_i2c()
832 cmd->scmd.done = smu_i2c_low_completion; in smu_queue_i2c()
833 cmd->scmd.misc = cmd; in smu_queue_i2c()
834 cmd->scmd.reply_buf = cmd->pdata; in smu_queue_i2c()
835 cmd->scmd.reply_len = sizeof(cmd->pdata); in smu_queue_i2c()
836 cmd->scmd.data_buf = (u8 *)(char *)&cmd->info; in smu_queue_i2c()
837 cmd->scmd.status = 1; in smu_queue_i2c()
838 cmd->stage = 0; in smu_queue_i2c()
839 cmd->pdata[0] = 0xff; in smu_queue_i2c()
840 cmd->retries = 20; in smu_queue_i2c()
841 cmd->status = 1; in smu_queue_i2c()
846 cmd->info.caddr = cmd->info.devaddr; in smu_queue_i2c()
847 cmd->read = cmd->info.devaddr & 0x01; in smu_queue_i2c()
848 switch(cmd->info.type) { in smu_queue_i2c()
850 cmd->info.sublen = 0; in smu_queue_i2c()
851 memset(cmd->info.subaddr, 0, sizeof(cmd->info.subaddr)); in smu_queue_i2c()
854 cmd->info.devaddr &= 0xfe; in smu_queue_i2c()
857 if (cmd->info.sublen > 3) in smu_queue_i2c()
866 if (cmd->read) { in smu_queue_i2c()
867 if (cmd->info.datalen > SMU_I2C_READ_MAX) in smu_queue_i2c()
869 memset(cmd->info.data, 0xff, cmd->info.datalen); in smu_queue_i2c()
870 cmd->scmd.data_len = 9; in smu_queue_i2c()
872 if (cmd->info.datalen > SMU_I2C_WRITE_MAX) in smu_queue_i2c()
874 cmd->scmd.data_len = 9 + cmd->info.datalen; in smu_queue_i2c()
879 cmd->read ? "read" : "write", cmd->info.datalen, in smu_queue_i2c()
880 cmd->info.bus, cmd->info.caddr, in smu_queue_i2c()
881 cmd->info.subaddr[0], cmd->info.type); in smu_queue_i2c()
889 smu->cmd_i2c_cur = cmd; in smu_queue_i2c()
890 list_add_tail(&cmd->scmd.link, &smu->cmd_list); in smu_queue_i2c()
894 list_add_tail(&cmd->link, &smu->cmd_i2c_list); in smu_queue_i2c()
908 struct smu_cmd cmd; in smu_read_datablock() local
920 cmd.cmd = SMU_CMD_MISC_ee_COMMAND; in smu_read_datablock()
921 cmd.data_len = 7; in smu_read_datablock()
922 cmd.data_buf = params; in smu_read_datablock()
923 cmd.reply_len = chunk; in smu_read_datablock()
924 cmd.reply_buf = dest; in smu_read_datablock()
925 cmd.done = smu_done_complete; in smu_read_datablock()
926 cmd.misc = &comp; in smu_read_datablock()
932 rc = smu_queue_cmd(&cmd); in smu_read_datablock()
936 if (cmd.status != 0) in smu_read_datablock()
938 if (cmd.reply_len != clen) { in smu_read_datablock()
941 cmd.reply_len, clen); in smu_read_datablock()
954 struct smu_simple_cmd cmd; in smu_create_sdb_partition() local
961 smu_queue_simple(&cmd, SMU_CMD_PARTITION_COMMAND, 2, in smu_create_sdb_partition()
966 cmd.cmd.status, cmd.cmd.reply_len); in smu_create_sdb_partition()
969 if (cmd.cmd.status != 0 || cmd.cmd.reply_len != 6) in smu_create_sdb_partition()
973 addr = *((u16 *)cmd.buffer); in smu_create_sdb_partition()
974 len = cmd.buffer[3] << 2; in smu_create_sdb_partition()
1076 struct smu_cmd cmd; member
1106 static void smu_user_cmd_done(struct smu_cmd *cmd, void *misc) in smu_user_cmd_done() argument
1131 part = __smu_get_sdb_partition(hdr.cmd, NULL, 1); in smu_write()
1150 pp->cmd.status = 1; in smu_write()
1158 pp->cmd.cmd = hdr.cmd; in smu_write()
1159 pp->cmd.data_len = hdr.data_len; in smu_write()
1160 pp->cmd.reply_len = SMU_MAX_DATA; in smu_write()
1161 pp->cmd.data_buf = pp->buffer; in smu_write()
1162 pp->cmd.reply_buf = pp->buffer; in smu_write()
1163 pp->cmd.done = smu_user_cmd_done; in smu_write()
1164 pp->cmd.misc = pp; in smu_write()
1165 rc = smu_queue_cmd(&pp->cmd); in smu_write()
1185 if (pp->cmd.status == 1) { in smu_read_command()
1194 if (pp->cmd.status != 1) in smu_read_command()
1209 if (pp->cmd.status != 0) in smu_read_command()
1210 pp->cmd.reply_len = 0; in smu_read_command()
1211 size = sizeof(hdr) + pp->cmd.reply_len; in smu_read_command()
1215 hdr.status = pp->cmd.status; in smu_read_command()
1216 hdr.reply_len = pp->cmd.reply_len; in smu_read_command()
1263 if (pp->busy && pp->cmd.status != 1) in smu_fpoll()
1290 if (busy && pp->cmd.status == 1) { in smu_release()
1296 if (pp->cmd.status != 1) in smu_release()