Commit 8568fe63 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: print a better message when fw version is wrong

The printed message when a firmware version is wrong says nothing
usefull:

	atomisp-isp2 0000:00:03.0: Fw version check failed.
	atomisp-isp2: probe of 0000:00:03.0 failed with error -22

Print the expected and the received firmware version instead.

In order to do that, the firmware functions will need at least
a struct device pointer, so pass it.

While writing this patch, it was noticed that some of the
abstraction layers of this driver have functions that are never
called, but use this interface. Get rid of them.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 1ab70982
......@@ -875,7 +875,7 @@ int atomisp_css_init(struct atomisp_device *isp)
return ret;
/* Init ISP */
err = ia_css_init(&isp->css_env.isp_css_env, NULL,
err = ia_css_init(isp->dev, &isp->css_env.isp_css_env, NULL,
(uint32_t)mmu_base_addr, IA_CSS_IRQ_TYPE_PULSE);
if (err != IA_CSS_SUCCESS) {
dev_err(isp->dev, "css init failed --- bad firmware?\n");
......@@ -909,8 +909,7 @@ static inline int __set_css_print_env(struct atomisp_device *isp, int opt)
int atomisp_css_check_firmware_version(struct atomisp_device *isp)
{
if (!sh_css_check_firmware_version((void *)isp->firmware->data)) {
dev_err(isp->dev, "Fw version check failed.\n");
if (!sh_css_check_firmware_version(isp->dev, (void *)isp->firmware->data)) {
return -EINVAL;
}
return 0;
......@@ -945,7 +944,7 @@ int atomisp_css_load_firmware(struct atomisp_device *isp)
isp->css_env.isp_css_env.print_env.error_print = atomisp_css2_err_print;
/* load isp fw into ISP memory */
err = ia_css_load_firmware(&isp->css_env.isp_css_env,
err = ia_css_load_firmware(isp->dev, &isp->css_env.isp_css_env,
&isp->css_env.isp_css_fw);
if (err != IA_CSS_SUCCESS) {
dev_err(isp->dev, "css load fw failed.\n");
......@@ -992,7 +991,7 @@ int atomisp_css_resume(struct atomisp_device *isp)
return -EINVAL;
}
ret = ia_css_init(&isp->css_env.isp_css_env, NULL,
ret = ia_css_init(isp->dev, &isp->css_env.isp_css_env, NULL,
mmu_base_addr, IA_CSS_IRQ_TYPE_PULSE);
if (ret) {
dev_err(isp->dev, "re-init css failed.\n");
......
......@@ -45,11 +45,11 @@
* contents of this firmware package are copied into local data structures, so
* the fw pointer could be freed after this function completes.
*/
enum ia_css_err ia_css_init(
const struct ia_css_env *env,
const struct ia_css_fw *fw,
u32 l1_base,
enum ia_css_irq_type irq_type);
enum ia_css_err ia_css_init(struct device *dev,
const struct ia_css_env *env,
const struct ia_css_fw *fw,
u32 l1_base,
enum ia_css_irq_type irq_type);
/* @brief Un-initialize the CSS API.
* @return None
......@@ -66,31 +66,6 @@ enum ia_css_err ia_css_init(
void
ia_css_uninit(void);
/* @brief Suspend CSS API for power down
* @return success or faulure code
*
* suspend shuts down the system by:
* unloading all the streams
* stopping SP
* performing uninit
*
* Currently stream memory is deallocated because of rmmgr issues.
* Need to come up with a bypass that will leave the streams intact.
*/
enum ia_css_err
ia_css_suspend(void);
/* @brief Resume CSS API from power down
* @return success or failure code
*
* After a power cycle, this function will bring the CSS API back into
* a state where it can be started.
* This will re-initialize the hardware and all the streams.
* Call this function only after ia_css_suspend() has been called.
*/
enum ia_css_err
ia_css_resume(void);
/* @brief Enable use of a separate queue for ISYS events.
*
* @param[in] enable: enable or disable use of separate ISYS event queues.
......
......@@ -48,7 +48,7 @@ struct ia_css_fw {
* firmware only needs to be loaded once).
*/
enum ia_css_err
ia_css_load_firmware(const struct ia_css_env *env,
ia_css_load_firmware(struct device *dev, const struct ia_css_env *env,
const struct ia_css_fw *fw);
/* @brief Unloads the firmware
......@@ -61,14 +61,4 @@ ia_css_load_firmware(const struct ia_css_env *env,
void
ia_css_unload_firmware(void);
/* @brief Checks firmware version
* @param[in] fw Firmware package containing the firmware for all
* predefined ISP binaries.
* @return Returns true when the firmware version matches with the CSS
* host code version and returns false otherwise.
* This function checks if the firmware package version matches with the CSS host code version.
*/
bool
ia_css_check_firmware_version(const struct ia_css_fw *fw);
#endif /* __IA_CSS_FIRMWARE_H */
......@@ -1619,19 +1619,8 @@ ia_css_reset_defaults(struct sh_css *css)
*css = default_css;
}
bool
ia_css_check_firmware_version(const struct ia_css_fw *fw)
{
bool retval = false;
if (fw) {
retval = sh_css_check_firmware_version(fw->data);
}
return retval;
}
enum ia_css_err
ia_css_load_firmware(const struct ia_css_env *env,
ia_css_load_firmware(struct device *dev, const struct ia_css_env *env,
const struct ia_css_fw *fw) {
enum ia_css_err err;
......@@ -1650,7 +1639,7 @@ ia_css_load_firmware(const struct ia_css_env *env,
}
ia_css_unload_firmware(); /* in case we are called twice */
err = sh_css_load_firmware(fw->data, fw->bytes);
err = sh_css_load_firmware(dev, fw->data, fw->bytes);
if (err == IA_CSS_SUCCESS)
{
err = ia_css_binary_init_infos();
......@@ -1663,7 +1652,7 @@ ia_css_load_firmware(const struct ia_css_env *env,
}
enum ia_css_err
ia_css_init(const struct ia_css_env *env,
ia_css_init(struct device *dev, const struct ia_css_env *env,
const struct ia_css_fw *fw,
u32 mmu_l1_base,
enum ia_css_irq_type irq_type) {
......@@ -1791,7 +1780,7 @@ ia_css_init(const struct ia_css_env *env,
if (fw)
{
ia_css_unload_firmware(); /* in case we already had firmware loaded */
err = sh_css_load_firmware(fw->data, fw->bytes);
err = sh_css_load_firmware(dev, fw->data, fw->bytes);
if (err != IA_CSS_SUCCESS) {
IA_CSS_LEAVE_ERR(err);
return err;
......@@ -1859,74 +1848,6 @@ ia_css_init(const struct ia_css_env *env,
return err;
}
enum ia_css_err ia_css_suspend(void)
{
int i;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_suspend() enter\n");
my_css_save.mode = sh_css_mode_suspend;
for (i = 0; i < MAX_ACTIVE_STREAMS; i++)
if (my_css_save.stream_seeds[i].stream) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "==*> unloading seed %d (%p)\n", i,
my_css_save.stream_seeds[i].stream);
ia_css_stream_unload(my_css_save.stream_seeds[i].stream);
}
my_css_save.mode = sh_css_mode_working;
ia_css_stop_sp();
ia_css_uninit();
for (i = 0; i < MAX_ACTIVE_STREAMS; i++)
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "==*> after 1: seed %d (%p)\n", i,
my_css_save.stream_seeds[i].stream);
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_suspend() leave\n");
return IA_CSS_SUCCESS;
}
enum ia_css_err
ia_css_resume(void) {
int i, j;
enum ia_css_err err;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_resume() enter: void\n");
err = ia_css_init(&my_css_save.driver_env, my_css_save.loaded_fw, my_css_save.mmu_base, my_css_save.irq_type);
if (err != IA_CSS_SUCCESS)
return err;
err = ia_css_start_sp();
if (err != IA_CSS_SUCCESS)
return err;
my_css_save.mode = sh_css_mode_resume;
for (i = 0; i < MAX_ACTIVE_STREAMS; i++)
{
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "==*> seed stream %p\n",
my_css_save.stream_seeds[i].stream);
if (my_css_save.stream_seeds[i].stream) {
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "==*> loading seed %d\n", i);
err = ia_css_stream_load(my_css_save.stream_seeds[i].stream);
if (err != IA_CSS_SUCCESS) {
if (i)
for (j = 0; j < i; j++)
ia_css_stream_unload(my_css_save.stream_seeds[j].stream);
return err;
}
err = ia_css_stream_start(my_css_save.stream_seeds[i].stream);
if (err != IA_CSS_SUCCESS) {
for (j = 0; j <= i; j++) {
ia_css_stream_stop(my_css_save.stream_seeds[j].stream);
ia_css_stream_unload(my_css_save.stream_seeds[j].stream);
}
return err;
}
*my_css_save.stream_seeds[i].orig_stream = my_css_save.stream_seeds[i].stream;
for (j = 0; j < my_css_save.stream_seeds[i].num_pipes; j++)
*my_css_save.stream_seeds[i].orig_pipes[j] =
my_css_save.stream_seeds[i].pipes[j];
}
}
my_css_save.mode = sh_css_mode_working;
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_resume() leave: return_void\n");
return IA_CSS_SUCCESS;
}
enum ia_css_err
ia_css_enable_isys_event_queue(bool enable) {
if (sh_css_sp_is_running())
......
......@@ -181,7 +181,7 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi,
}
bool
sh_css_check_firmware_version(const char *fw_data)
sh_css_check_firmware_version(struct device *dev, const char *fw_data)
{
struct sh_css_fw_bi_file_h *file_header;
......@@ -196,6 +196,8 @@ sh_css_check_firmware_version(const char *fw_data)
file_header = &firmware_header->file_header;
if (strcmp(file_header->version, release_version) != 0) {
dev_err(dev, "Fw version check failed. Expecting '%s', firmware is '%s'.\n",
release_version, file_header->version);
return false;
} else {
/* firmware version matches */
......@@ -204,7 +206,7 @@ sh_css_check_firmware_version(const char *fw_data)
}
enum ia_css_err
sh_css_load_firmware(const char *fw_data,
sh_css_load_firmware(struct device *dev, const char *fw_data,
unsigned int fw_size) {
unsigned int i;
struct ia_css_fw_info *binaries;
......@@ -221,7 +223,7 @@ sh_css_load_firmware(const char *fw_data,
file_header = &firmware_header->file_header;
binaries = &firmware_header->binary_header;
strncpy(FW_rel_ver_name, file_header->version, min(sizeof(FW_rel_ver_name), sizeof(file_header->version)) - 1);
valid_firmware = sh_css_check_firmware_version(fw_data);
valid_firmware = sh_css_check_firmware_version(dev, fw_data);
if (!valid_firmware) {
IA_CSS_ERROR("CSS code version (%s) and firmware version (%s) mismatch!",
file_header->version, release_version);
......
......@@ -38,10 +38,10 @@ char
*sh_css_get_fw_version(void);
bool
sh_css_check_firmware_version(const char *fw_data);
sh_css_check_firmware_version(struct device *dev, const char *fw_data);
enum ia_css_err
sh_css_load_firmware(const char *fw_data,
sh_css_load_firmware(struct device *dev, const char *fw_data,
unsigned int fw_size);
void sh_css_unload_firmware(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment