return rval;
}
+static int ccs_firmware_name(struct i2c_client *client,
+ struct ccs_sensor *sensor, char *filename,
+ size_t filename_size, bool is_module)
+{
+ const struct ccs_device *ccsdev = device_get_match_data(&client->dev);
+ bool is_ccs = !(ccsdev->flags & CCS_DEVICE_FLAG_IS_SMIA);
+ bool is_smiapp = sensor->minfo.smiapp_version;
+ u16 manufacturer_id;
+ u16 model_id;
+ u16 revision_number;
+
+ /*
+ * Old SMIA is module-agnostic. Its sensor identification is based on
+ * what now are those of the module.
+ */
+ if (is_module || (!is_ccs && !is_smiapp)) {
+ manufacturer_id = is_ccs ?
+ sensor->minfo.mipi_manufacturer_id :
+ sensor->minfo.smia_manufacturer_id;
+ model_id = sensor->minfo.model_id;
+ revision_number = sensor->minfo.revision_number;
+ } else {
+ manufacturer_id = is_ccs ?
+ sensor->minfo.sensor_mipi_manufacturer_id :
+ sensor->minfo.sensor_smia_manufacturer_id;
+ model_id = sensor->minfo.sensor_model_id;
+ revision_number = sensor->minfo.sensor_revision_number;
+ }
+
+ return snprintf(filename, filename_size,
+ "ccs/%s-%s-%0*x-%4.4x-%0*x.fw",
+ is_ccs ? "ccs" : is_smiapp ? "smiapp" : "smia",
+ is_module || (!is_ccs && !is_smiapp) ?
+ "module" : "sensor",
+ is_ccs ? 4 : 2, manufacturer_id, model_id,
+ !is_ccs && !is_module ? 2 : 4, revision_number);
+}
+
static int ccs_probe(struct i2c_client *client)
{
+ const struct ccs_device *ccsdev = device_get_match_data(&client->dev);
struct ccs_sensor *sensor;
const struct firmware *fw;
char filename[40];
goto out_power_off;
}
- rval = snprintf(filename, sizeof(filename),
- "ccs/ccs-sensor-%4.4x-%4.4x-%4.4x.fw",
- sensor->minfo.sensor_mipi_manufacturer_id,
- sensor->minfo.sensor_model_id,
- sensor->minfo.sensor_revision_number);
+ rval = ccs_firmware_name(client, sensor, filename, sizeof(filename),
+ false);
if (rval >= sizeof(filename)) {
rval = -ENOMEM;
goto out_power_off;
release_firmware(fw);
}
- rval = snprintf(filename, sizeof(filename),
- "ccs/ccs-module-%4.4x-%4.4x-%4.4x.fw",
- sensor->minfo.mipi_manufacturer_id,
- sensor->minfo.model_id,
- sensor->minfo.revision_number);
- if (rval >= sizeof(filename)) {
- rval = -ENOMEM;
- goto out_release_sdata;
- }
+ if (!(ccsdev->flags & CCS_DEVICE_FLAG_IS_SMIA) ||
+ sensor->minfo.smiapp_version) {
+ rval = ccs_firmware_name(client, sensor, filename,
+ sizeof(filename), true);
+ if (rval >= sizeof(filename)) {
+ rval = -ENOMEM;
+ goto out_release_sdata;
+ }
- rval = request_firmware(&fw, filename, &client->dev);
- if (!rval) {
- ccs_data_parse(&sensor->mdata, fw->data, fw->size, &client->dev,
- true);
- release_firmware(fw);
+ rval = request_firmware(&fw, filename, &client->dev);
+ if (!rval) {
+ ccs_data_parse(&sensor->mdata, fw->data, fw->size,
+ &client->dev, true);
+ release_firmware(fw);
+ }
}
rval = ccs_read_all_limits(sensor);