Commit 7b9f1830 authored by Charlie Mooney's avatar Charlie Mooney Committed by Dmitry Torokhov

Input: elan_i2c - add product IDs FW names

Previously the elan_i2c touchpad driver would simply request the firmware
"/lib/firmware/elan_i2c.bin", which does not work well if there are
multiple such devices in the system.

Let's append the "product ID" (by using the same function as the sysfs
interface for consistency) to the filename.  This results in filenames of
the form "/lib/firmware/elan_i2c_72.0.bin", allowing you to support
multiple elan_i2c touchpads on the same device by simply naming each
device's FW with its corresponding product ID.  This way when you trigger a
fw update the driver will load the correct binary.
Signed-off-by: default avatarCharlie Mooney <charliemooney@chromium.org>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 12018ac3
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
#define ETP_PRESSURE_OFFSET 25 #define ETP_PRESSURE_OFFSET 25
/* IAP Firmware handling */ /* IAP Firmware handling */
#define ETP_FW_NAME "elan_i2c.bin" #define ETP_PRODUCT_ID_FORMAT_STRING "%d.0"
#define ETP_FW_NAME "elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
#define ETP_IAP_START_ADDR 0x0083 #define ETP_IAP_START_ADDR 0x0083
#define ETP_FW_IAP_PAGE_ERR (1 << 5) #define ETP_FW_IAP_PAGE_ERR (1 << 5)
#define ETP_FW_IAP_INTF_ERR (1 << 4) #define ETP_FW_IAP_INTF_ERR (1 << 4)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* Copyright (c) 2013 ELAN Microelectronics Corp. * Copyright (c) 2013 ELAN Microelectronics Corp.
* *
* Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw> * Author: 林政維 (Duson Lin) <dusonlin@emc.com.tw>
* Version: 1.5.8 * Version: 1.5.9
* *
* Based on cyapa driver: * Based on cyapa driver:
* copyright (c) 2011-2012 Cypress Semiconductor, Inc. * copyright (c) 2011-2012 Cypress Semiconductor, Inc.
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include "elan_i2c.h" #include "elan_i2c.h"
#define DRIVER_NAME "elan_i2c" #define DRIVER_NAME "elan_i2c"
#define ELAN_DRIVER_VERSION "1.5.8" #define ELAN_DRIVER_VERSION "1.5.9"
#define ETP_MAX_PRESSURE 255 #define ETP_MAX_PRESSURE 255
#define ETP_FWIDTH_REDUCE 90 #define ETP_FWIDTH_REDUCE 90
#define ETP_FINGER_WIDTH 15 #define ETP_FINGER_WIDTH 15
...@@ -438,7 +438,8 @@ static ssize_t elan_sysfs_read_product_id(struct device *dev, ...@@ -438,7 +438,8 @@ static ssize_t elan_sysfs_read_product_id(struct device *dev,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
struct elan_tp_data *data = i2c_get_clientdata(client); struct elan_tp_data *data = i2c_get_clientdata(client);
return sprintf(buf, "%d.0\n", data->product_id); return sprintf(buf, ETP_PRODUCT_ID_FORMAT_STRING "\n",
data->product_id);
} }
static ssize_t elan_sysfs_read_fw_ver(struct device *dev, static ssize_t elan_sysfs_read_fw_ver(struct device *dev,
...@@ -477,14 +478,23 @@ static ssize_t elan_sysfs_update_fw(struct device *dev, ...@@ -477,14 +478,23 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
{ {
struct elan_tp_data *data = dev_get_drvdata(dev); struct elan_tp_data *data = dev_get_drvdata(dev);
const struct firmware *fw; const struct firmware *fw;
char *fw_name;
int error; int error;
const u8 *fw_signature; const u8 *fw_signature;
static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF}; static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF};
error = request_firmware(&fw, ETP_FW_NAME, dev); /* Look for a firmware with the product id appended. */
fw_name = kasprintf(GFP_KERNEL, ETP_FW_NAME, data->product_id);
if (!fw_name) {
dev_err(dev, "failed to allocate memory for firmware name\n");
return -ENOMEM;
}
dev_info(dev, "requesting fw '%s'\n", fw_name);
error = request_firmware(&fw, fw_name, dev);
kfree(fw_name);
if (error) { if (error) {
dev_err(dev, "cannot load firmware %s: %d\n", dev_err(dev, "failed to request firmware: %d\n", error);
ETP_FW_NAME, error);
return error; return error;
} }
......
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