Skip to content

Commit b1dbe7d

Browse files
authored
Merge pull request #4 from intel/post_beta
Post beta
2 parents eac6851 + 067a4f9 commit b1dbe7d

File tree

3 files changed

+61
-68
lines changed

3 files changed

+61
-68
lines changed

drivers/misc/icvs/intel_cvs.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@ static enum hrtimer_restart cvs_wdt_reset(struct hrtimer *t)
9494
return HRTIMER_NORESTART;
9595
}
9696

97+
static int find_oem_prod_id(acpi_handle handle, const char* method_name, unsigned long long* value)
98+
{
99+
acpi_status status;
100+
101+
status = acpi_evaluate_integer(handle, (acpi_string)method_name,
102+
NULL, value);
103+
104+
if (ACPI_FAILURE(status)) {
105+
dev_err(cvs->dev, "%s: ACPI method %s not found",
106+
__func__, method_name);
107+
return status;
108+
}
109+
110+
dev_info(cvs->dev,
111+
"%s: ACPI method %s returned oem_prod_id:0x%llx",
112+
__func__, method_name, *value);
113+
return 0;
114+
}
115+
97116
static int find_shared_i2c(acpi_handle handle, const char *method_name)
98117
{
99118
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -215,6 +234,7 @@ static int cvs_i2c_probe(struct i2c_client *i2c)
215234
icvs->i2c_shared = (find_shared_i2c(handle, "IICS") < 0) ? 0 : 1;
216235

217236
if (icvs->cap == ICVS_FULLCAP) {
237+
find_oem_prod_id(handle, "OPID", &(icvs->oem_prod_id));
218238
/* Start FW D/L task cvs_fw_dl_thread() */
219239
mdelay(FW_PREPARE_MS);
220240
cvs_release_camera_sensor_internal();
@@ -606,7 +626,10 @@ static int cvs_resume(struct device *dev)
606626
if (val < 0)
607627
dev_err(icvs->dev, "%s: Failed to read gpio via usb bridge\n", __func__);
608628

609-
if (icvs->cap == ICVS_FULLCAP) {
629+
if (icvs->cap == ICVS_FULLCAP) {
630+
icvs->fw_dl_task_finished = false;
631+
icvs->close_fw_dl_task = false;
632+
610633
/* Restart IRQ and wdt, hrtimer_start would start by fw_dl_task */
611634
enable_irq(icvs->irq);
612635
schedule_work(&icvs->fw_dl_task);

drivers/misc/icvs/intel_cvs_update.c

Lines changed: 35 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,11 @@ int cvs_dev_fw_dl(void)
362362
}
363363

364364
if (!status) {
365-
status = cvs_wait_for_host_wake(WAIT_HOST_WAKE_RESET_MS);
365+
if (cvs_wait_for_host_wake(WAIT_HOST_WAKE_RESET_MS)) {
366+
dev_err(cvs->dev, "%s:CV reset FW boot hostwake error",
367+
__func__);
368+
return -ETIMEDOUT;
369+
}
366370
}
367371

368372
dev_info(cvs->dev, "%s:Exit with status:0x%x", __func__, status);
@@ -392,51 +396,6 @@ static int cvs_get_fwver_vid_pid(void)
392396
return 0;
393397
}
394398

395-
static bool iterate_files(struct dir_context *fdir, const char *name,
396-
int namelen, loff_t offset, u64 ino,
397-
unsigned int d_type)
398-
{
399-
if (d_type == DT_REG &&
400-
strncmp(name, cvs->file_prefix, strlen(cvs->file_prefix)) == 0) {
401-
dev_dbg(cvs->dev, "%s:File found: %s ", __func__, name);
402-
cvs->fw_filename = (char *)devm_kzalloc(
403-
cvs->dev, strlen(name) + 1, GFP_KERNEL);
404-
strcpy(cvs->fw_filename, name);
405-
cvs->fw_bin_file_found = true;
406-
407-
/* Return 'false' to stop (OR) if there are no more entries */
408-
return false;
409-
}
410-
411-
/* Return 'true' to keep going */
412-
return true;
413-
}
414-
415-
static bool cvs_search_fw_file(void)
416-
{
417-
struct file *filp;
418-
struct dir_context fdir = { 0 };
419-
int ret;
420-
const char *path_to_search = "/lib/firmware/";
421-
422-
sprintf(cvs->file_prefix, "%d-%d", cvs->id.vid, cvs->id.pid);
423-
dev_dbg(cvs->dev, "%s:VID-PID as string: %s", __func__,
424-
cvs->file_prefix);
425-
426-
filp = filp_open(path_to_search, O_RDONLY | O_DIRECTORY, 0);
427-
if (IS_ERR_OR_NULL(filp)) {
428-
dev_err(cvs->dev, "%s:Failed to open directory: %ld", __func__,
429-
PTR_ERR(filp));
430-
return PTR_ERR(filp);
431-
}
432-
433-
fdir.actor = iterate_files;
434-
fdir.pos = 0;
435-
ret = iterate_dir(filp, &fdir);
436-
filp_close(filp, NULL);
437-
return cvs->fw_bin_file_found;
438-
}
439-
440399
static u32 cvs_calc_checksum(void *data)
441400
{
442401
int i;
@@ -481,7 +440,7 @@ static int cvs_fw_parse(void)
481440
ptr_fw_header->fw_ver.hotfix,
482441
ptr_fw_header->fw_ver.build);
483442

484-
dev_info(cvs->dev, "%s:Lib VID:%d, PID:%d, fw_offset:%d",
443+
dev_info(cvs->dev, "%s:Lib VID:0X%x, PID:0x%x, fw_offset:0x%x",
485444
__func__, ptr_fw_header->vid_pid.vid,
486445
ptr_fw_header->vid_pid.pid,
487446
ptr_fw_header->fw_offset);
@@ -502,37 +461,46 @@ static int cvs_fw_parse(void)
502461
(cvs->ver.hotfix != ptr_fw_header->fw_ver.hotfix) ||
503462
(cvs->ver.build != ptr_fw_header->fw_ver.build)) {
504463
cvs->fw_dl_needed = true;
505-
dev_info(cvs->dev, "%s:FW update needed", __func__);
506-
} else
464+
dev_dbg(cvs->dev, "%s:FW update needed", __func__);
465+
}
466+
else {
467+
cvs->fw_dl_needed = false;
507468
dev_info(cvs->dev, "%s:FW update not needed", __func__);
469+
}
508470

509471
return 0;
510472
}
511473

512474
static bool evaluate_fw(void)
513475
{
514476
int ret, status = 1;
515-
dev_info(cvs->dev, "%s:file name is %s : %p\n", __func__,
516-
cvs->fw_filename, cvs->dev);
517-
ret = firmware_request_nowarn(&cvs->file, cvs->fw_filename, cvs->dev);
477+
478+
if (cvs->oem_prod_id) {
479+
sprintf(cvs->fw_filename, "cvs/%04X%04X-%04llX.bin",
480+
cvs->id.vid, cvs->id.pid, cvs->oem_prod_id);
481+
}
482+
else
483+
sprintf(cvs->fw_filename, "cvs/%04X%04X.bin",
484+
cvs->id.vid, cvs->id.pid);
485+
486+
ret = request_firmware(&cvs->file, cvs->fw_filename, cvs->dev);
518487
if (ret) {
519488
dev_err(cvs->dev,
520-
"%s:firmware_request_nowarn() fail with ret:%d\n",
489+
"%s:request_firmware() fail with ret:%d",
521490
__func__, ret);
522491
return ret;
523492
}
524493

525494
dev_dbg(cvs->dev,
526-
"%s:firmware_request() pass with name:%s, data:%p, size:%d\n",
527-
__func__, cvs->fw_filename, cvs->file->data,
528-
(int)cvs->file->size);
495+
"%s: FW bin file found with file_ptr:%p, size:0x%x",
496+
__func__, cvs->file->data, (int)cvs->file->size);
529497

530498
/* Alloc memory for FW Image Buffer */
531499
cvs->fw_buffer_size = cvs->file->size;
532500
cvs->fw_buffer =
533501
devm_kzalloc(cvs->dev, cvs->fw_buffer_size, GFP_KERNEL);
534502
if (IS_ERR_OR_NULL(cvs->fw_buffer)) {
535-
dev_err(cvs->dev, "%s:NO memory for fw_buffer", __func__);
503+
dev_err(cvs->dev, "%s:No memory for fw_buffer", __func__);
536504
status = -ENOMEM;
537505
goto err_fw_release;
538506
}
@@ -546,8 +514,7 @@ static bool evaluate_fw(void)
546514

547515
status = cvs_fw_parse();
548516
if (status) {
549-
dev_err(cvs->dev, "%s:cvs_fw_parse() fail with status:%d\n",
550-
__func__, status);
517+
dev_err(cvs->dev, "%s: FW bin file is invalid", __func__);
551518
goto err_fw_release;
552519
}
553520

@@ -594,15 +561,19 @@ void cvs_fw_dl_thread(struct work_struct *arg)
594561
}
595562
cvs->icvs_sensor_state = CV_SENSOR_VISION_ACQUIRED_STATE;
596563

597-
if (!cvs_get_fwver_vid_pid() && cvs_search_fw_file()) {
598-
dev_info(cvs->dev, "%s:FW file found", __func__);
564+
if (!cvs_get_fwver_vid_pid()) {
565+
dev_info(cvs->dev, "%s:Device FW version is %d.%d.%d.%d",
566+
__func__, cvs->ver.major, cvs->ver.minor,
567+
cvs->ver.hotfix, cvs->ver.build);
599568
if (evaluate_fw()) {
600-
dev_err(cvs->dev, "%s:FW file found is invalid",
569+
dev_err(cvs->dev, "%s:FW file not found",
601570
__func__);
602571
goto err_exit;
603572
}
604-
} else {
605-
dev_info(cvs->dev, "%s:FW file not found", __func__);
573+
}
574+
else {
575+
dev_info(cvs->dev, "%s:I2C error. Not able to read vid/pid",
576+
__func__);
606577
goto err_exit;
607578
}
608579

include/linux/intel_cvs.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct intel_cvs {
158158
enum icvs_sensor_state icvs_sensor_state;
159159

160160
int i2c_shared;
161+
unsigned long long oem_prod_id;
161162
enum cvs_camera_owner owner;
162163
int ref_count;
163164
int int_ref_count;
@@ -171,11 +172,9 @@ struct intel_cvs {
171172
u32 fw_file_path[_MAX_PATH];
172173
void* fw_buffer;
173174
u32 fw_buffer_size;
174-
bool fw_bin_file_found;
175175
u32 max_flashtime_ms;
176176
u8 cv_fw_state;
177-
char* fw_filename;
178-
char file_prefix[64];
177+
char fw_filename[24];
179178
bool fw_dl_task_finished;
180179
bool fw_dl_needed;
181180
bool close_fw_dl_task;

0 commit comments

Comments
 (0)