From: Nick Dyer <nick.dyer@itdev.co.uk>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Daniel Kurtz <djkurtz@chromium.org>,
Henrik Rydberg <rydberg@euromail.se>,
Joonyoung Shim <jy0922.shim@samsung.com>,
Alan Bowens <Alan.Bowens@atmel.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Meerwald <pmeerw@pmeerw.net>,
Benson Leung <bleung@chromium.org>,
Olof Johansson <olofj@chromium.org>,
Nick Dyer <nick.dyer@itdev.co.uk>
Subject: [PATCH 50/51] Input: atmel_mxt_ts - Handle cfg filename via pdata/sysfs
Date: Thu, 27 Jun 2013 13:49:25 +0100 [thread overview]
Message-ID: <1372337366-9286-51-git-send-email-nick.dyer@itdev.co.uk> (raw)
In-Reply-To: <1372337366-9286-1-git-send-email-nick.dyer@itdev.co.uk>
There may be multiple maXTouch chips on a single device which will require
different configuration files. Add a platform data value for the configuration
filename.
Add sysfs entry to write configuration file if the platform data is not set.
Split out the object initialisation code from mxt_initialize() into
mxt_configure_objects() to allow this.
Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 104 ++++++++++++++++++++++++------
include/linux/i2c/atmel_mxt_ts.h | 1 +
2 files changed, 86 insertions(+), 19 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 9aa3a26..9a5ac2c 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -28,7 +28,6 @@
#include <linux/gpio.h>
/* Configuration file */
-#define MXT_CFG_NAME "maxtouch.cfg"
#define MXT_CFG_MAGIC "OBP_RAW V1"
/* Registers */
@@ -246,6 +245,7 @@ struct mxt_data {
struct regulator *reg_vdd;
struct regulator *reg_avdd;
char *fw_name;
+ char *cfg_name;
/* Cached parameters from object table */
u16 T5_address;
@@ -1372,10 +1372,15 @@ static int mxt_check_reg_init(struct mxt_data *data)
u8 val;
u16 reg;
- ret = request_firmware(&cfg, MXT_CFG_NAME, dev);
+ if (!data->cfg_name) {
+ dev_dbg(dev, "Skipping cfg download\n");
+ return 0;
+ }
+
+ ret = request_firmware(&cfg, data->cfg_name, dev);
if (ret < 0) {
dev_err(dev, "Failure to request config file %s\n",
- MXT_CFG_NAME);
+ data->cfg_name);
return 0;
}
@@ -1673,6 +1678,14 @@ static int mxt_acquire_irq(struct mxt_data *data)
return 0;
}
+static void mxt_free_input_device(struct mxt_data *data)
+{
+ if (data->input_dev) {
+ input_unregister_device(data->input_dev);
+ data->input_dev = NULL;
+ }
+}
+
static void mxt_free_object_table(struct mxt_data *data)
{
kfree(data->raw_info_block);
@@ -1682,10 +1695,7 @@ static void mxt_free_object_table(struct mxt_data *data)
kfree(data->msg_buf);
data->msg_buf = NULL;
- if (data->input_dev) {
- input_unregister_device(data->input_dev);
- data->input_dev = NULL;
- }
+ mxt_free_input_device(data);
data->enable_reporting = false;
data->T5_address = 0;
@@ -2181,6 +2191,7 @@ err_free_mem:
}
static int mxt_initialize_t9_input_device(struct mxt_data *data);
+static int mxt_configure_objects(struct mxt_data *data);
static int mxt_initialize(struct mxt_data *data)
{
@@ -2224,16 +2235,28 @@ retry_bootloader:
error = mxt_check_retrigen(data);
if (error)
- goto err_free_object_table;
+ return error;
error = mxt_acquire_irq(data);
if (error)
- goto err_free_object_table;
+ return error;
+
+ error = mxt_configure_objects(data);
+ if (error)
+ return error;
+
+ return 0;
+}
+
+static int mxt_configure_objects(struct mxt_data *data)
+{
+ struct i2c_client *client = data->client;
+ int error;
error = mxt_init_t7_power_cfg(data);
if (error) {
dev_err(&client->dev, "Failed to initialize power cfg\n");
- goto err_free_object_table;
+ return error;
}
/* Check register init values */
@@ -2241,28 +2264,23 @@ retry_bootloader:
if (error) {
dev_err(&client->dev, "Error %d initialising configuration\n",
error);
- goto err_free_object_table;
+ return error;
}
if (data->T9_reportid_min) {
error = mxt_initialize_t9_input_device(data);
if (error)
- goto err_free_object_table;
+ return error;
} else if (data->T100_reportid_min) {
error = mxt_initialize_t100_input_device(data);
if (error)
- goto err_free_object_table;
+ return error;
} else {
dev_warn(&client->dev, "No touch object detected\n");
}
data->enable_reporting = true;
-
return 0;
-
-err_free_object_table:
- mxt_free_object_table(data);
- return error;
}
/* Firmware Version is returned as Major.Minor.Build */
@@ -2550,16 +2568,57 @@ static ssize_t mxt_update_fw_store(struct device *dev,
return count;
}
+static ssize_t mxt_update_cfg_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct mxt_data *data = dev_get_drvdata(dev);
+ int ret;
+
+ if (data->in_bootloader) {
+ dev_err(dev, "Not in appmode\n");
+ return -EINVAL;
+ }
+
+ ret = mxt_update_file_name(dev, &data->cfg_name, buf, count);
+ if (ret)
+ return ret;
+
+ data->enable_reporting = false;
+ mxt_free_input_device(data);
+
+ if (data->suspended) {
+ if (data->use_regulator)
+ mxt_regulator_enable(data);
+ else
+ mxt_set_t7_power_cfg(data, MXT_POWER_CFG_RUN);
+
+ mxt_acquire_irq(data);
+
+ data->suspended = false;
+ }
+
+ ret = mxt_configure_objects(data);
+ if (ret)
+ goto out;
+
+ ret = count;
+out:
+ return ret;
+}
+
static DEVICE_ATTR(fw_version, S_IRUGO, mxt_fw_version_show, NULL);
static DEVICE_ATTR(hw_version, S_IRUGO, mxt_hw_version_show, NULL);
static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL);
static DEVICE_ATTR(update_fw, S_IWUSR, NULL, mxt_update_fw_store);
+static DEVICE_ATTR(update_cfg, S_IWUSR, NULL, mxt_update_cfg_store);
static struct attribute *mxt_attrs[] = {
&dev_attr_fw_version.attr,
&dev_attr_hw_version.attr,
&dev_attr_object.attr,
&dev_attr_update_fw.attr,
+ &dev_attr_update_cfg.attr,
NULL
};
@@ -2644,8 +2703,15 @@ static int mxt_handle_pdata(struct mxt_data *data)
data->pdata = dev_get_platdata(&data->client->dev);
/* Use provided platform data if present */
- if (data->pdata)
+ if (data->pdata) {
+ if (data->pdata->cfg_name)
+ mxt_update_file_name(&data->client->dev,
+ &data->cfg_name,
+ data->pdata->cfg_name,
+ strlen(data->pdata->cfg_name));
+
return 0;
+ }
data->pdata = kzalloc(sizeof(*data->pdata), GFP_KERNEL);
if (!data->pdata) {
diff --git a/include/linux/i2c/atmel_mxt_ts.h b/include/linux/i2c/atmel_mxt_ts.h
index a01f2e8..3422bd0 100644
--- a/include/linux/i2c/atmel_mxt_ts.h
+++ b/include/linux/i2c/atmel_mxt_ts.h
@@ -23,6 +23,7 @@ struct mxt_platform_data {
int t15_num_keys;
const unsigned int *t15_keymap;
unsigned long gpio_reset;
+ const char *cfg_name;
};
#endif /* __LINUX_ATMEL_MXT_TS_H */
--
1.7.10.4
next prev parent reply other threads:[~2013-06-27 12:51 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-27 12:48 Atmel updates to atmel_mxt_ts touch controller driver - v6 Nick Dyer
2013-06-27 12:48 ` [PATCH 01/51] Input: atmel_mxt_ts - Remove unnecessary platform data Nick Dyer
2013-06-27 12:48 ` [PATCH 02/51] Input: atmel_mxt_ts - Improve T19 GPIO keys handling Nick Dyer
2013-07-18 17:11 ` rydberg
2013-06-27 12:48 ` [PATCH 03/51] Input: atmel_mxt_ts - Return IRQ_NONE when interrupt handler fails Nick Dyer
2013-06-27 12:48 ` [PATCH 04/51] Input: atmel_mxt_ts - define helper functions for size and instances Nick Dyer
2013-06-27 12:48 ` [PATCH 05/51] Input: atmel_mxt_ts - Select FW_LOADER for firmware code Nick Dyer
2013-06-27 12:48 ` [PATCH 06/51] Input: atmel_mxt_ts - wait for CHG assert in mxt_check_bootloader Nick Dyer
2013-06-27 12:48 ` [PATCH 07/51] Input: atmel_mxt_ts - wait for CHG after bootloader resets Nick Dyer
2013-06-27 12:48 ` [PATCH 08/51] Input: atmel_mxt_ts - Initialise IRQ before probing Nick Dyer
2013-07-18 17:13 ` rydberg
2013-06-27 12:48 ` [PATCH 09/51] Input: atmel_mxt_ts - Make wait-after-reset period compatible with all chips Nick Dyer
2013-06-27 12:48 ` [PATCH 10/51] Input: atmel_mxt_ts - Improve error reporting and debug Nick Dyer
2013-06-27 12:48 ` [PATCH 11/51] Input: atmel_mxt_ts - Implement CRC check for configuration data Nick Dyer
2013-09-18 16:59 ` [11/51] " Martin Fuzzey
2013-06-27 12:48 ` [PATCH 12/51] Input: atmel_mxt_ts - Download device config using firmware loader Nick Dyer
2013-09-18 17:08 ` [12/51] " Martin Fuzzey
2013-06-27 12:48 ` [PATCH 13/51] Input: atmel_mxt_ts - Calculate and check CRC in config file Nick Dyer
2013-06-27 12:48 ` [PATCH 14/51] Input: atmel_mxt_ts - Add additional bootloader addresses Nick Dyer
2013-06-27 12:48 ` [PATCH 15/51] Input: atmel_mxt_ts - Read and report bootloader version Nick Dyer
2013-06-27 12:48 ` [PATCH 16/51] Input: atmel_mxt_ts - Implement bootloader frame retries Nick Dyer
2013-06-27 12:48 ` [PATCH 17/51] Input: atmel_mxt_ts - Improve bootloader progress output Nick Dyer
2013-06-27 12:48 ` [PATCH 18/51] Input: atmel_mxt_ts - Add check for incorrect firmware file format Nick Dyer
2013-06-27 12:48 ` [PATCH 19/51] Input: atmel_mxt_ts - Read screen config from chip Nick Dyer
2013-06-27 12:48 ` [PATCH 20/51] Input: atmel_mxt_ts - Set default irqflags when there is no pdata Nick Dyer
2013-07-18 17:17 ` rydberg
2013-09-16 2:25 ` Dmitry Torokhov
2014-05-22 14:29 ` Nick Dyer
2014-05-23 16:37 ` Yufeng Shen
2014-05-24 12:41 ` Nick Dyer
2014-05-26 18:17 ` Yufeng Shen
2014-05-26 5:23 ` Dmitry Torokhov
2014-05-26 18:13 ` Yufeng Shen
2013-06-27 12:48 ` [PATCH 21/51] Input: atmel_mxt_ts - Use deep sleep mode when stopped Nick Dyer
2013-06-27 12:48 ` [PATCH 22/51] Input: atmel_mxt_ts - Add shutdown function Nick Dyer
2013-07-07 5:29 ` Dmitry Torokhov
2013-07-08 9:56 ` Nick Dyer
2013-07-10 16:55 ` Dmitry Torokhov
2013-07-10 18:32 ` Nick Dyer
2013-06-27 12:48 ` [PATCH 23/51] Input: atmel_mxt_ts - Rename pressure to amplitude to match spec Nick Dyer
2013-06-27 12:48 ` [PATCH 24/51] Input: atmel_mxt_ts - Rename touchscreen defines to include T9 Nick Dyer
2013-06-27 12:49 ` [PATCH 25/51] Input: atmel_mxt_ts - Handle multiple input reports in one message Nick Dyer
2013-07-18 17:18 ` rydberg
2013-06-27 12:49 ` [PATCH 26/51] Input: atmel_mxt_ts - Move input device init into separate function Nick Dyer
2013-07-07 5:34 ` Dmitry Torokhov
2013-07-08 9:41 ` Nick Dyer
2013-07-10 16:53 ` Dmitry Torokhov
2013-07-18 17:20 ` rydberg
2013-06-27 12:49 ` [PATCH 27/51] Input: atmel_mxt_ts - Handle APP_CRC_FAIL on startup Nick Dyer
2013-06-27 12:49 ` [PATCH 28/51] Input: atmel_mxt_ts - Handle bootloader previously unlocked Nick Dyer
2013-06-27 12:49 ` [PATCH 29/51] Input: atmel_mxt_ts - Add bootloader addresses for new chips Nick Dyer
2013-06-27 12:49 ` [PATCH 30/51] Input: atmel_mxt_ts - Recover from bootloader on probe Nick Dyer
2013-06-27 12:49 ` [PATCH 31/51] Input: atmel_mxt_ts - Add support for dynamic message size Nick Dyer
2013-06-27 12:49 ` [PATCH 32/51] Input: atmel_mxt_ts - Decode T6 status messages Nick Dyer
2013-06-27 12:49 ` [PATCH 33/51] Input: atmel_mxt_ts - Split message handler into separate functions Nick Dyer
2013-06-27 12:49 ` [PATCH 34/51] Input: atmel_mxt_ts - Implement T44 message handling Nick Dyer
2013-06-27 12:49 ` [PATCH 35/51] Input: atmel_mxt_ts - Output status from T48 Noise Supression Nick Dyer
2013-06-27 12:49 ` [PATCH 36/51] Input: atmel_mxt_ts - Output status from T42 Touch Suppression Nick Dyer
2013-06-27 12:49 ` [PATCH 37/51] Input: atmel_mxt_ts - Implement vector/orientation support Nick Dyer
2013-07-18 17:20 ` rydberg
2013-08-15 16:18 ` Nick Dyer
2013-06-27 12:49 ` [PATCH 38/51] Input: atmel_mxt_ts - implement I2C retries Nick Dyer
2013-06-27 12:49 ` [PATCH 39/51] Input: atmel_mxt_ts - Implement T63 Active Stylus support Nick Dyer
2013-07-18 17:21 ` rydberg
2013-06-27 12:49 ` [PATCH 40/51] Input: atmel_mxt_ts - Implement support for T15 Key Array Nick Dyer
2013-06-27 12:49 ` [PATCH 41/51] Input: atmel_mxt_ts - Remove unused defines Nick Dyer
2013-06-27 12:49 ` [PATCH 42/51] Input: atmel_mxt_ts - Verify Information Block checksum on probe Nick Dyer
2013-06-27 12:49 ` [PATCH 43/51] Input: atmel_mxt_ts - Use T18 RETRIGEN to handle IRQF_TRIGGER_LOW Nick Dyer
2013-06-27 12:49 ` [PATCH 44/51] Input: atmel_mxt_ts - Handle reports from T47 Stylus object Nick Dyer
2013-07-18 17:23 ` rydberg
2013-06-27 12:49 ` [PATCH 45/51] Input: atmel_mxt_ts - Release touch state during suspend Nick Dyer
2013-07-18 17:29 ` rydberg
2013-08-15 15:52 ` Nick Dyer
2013-06-27 12:49 ` [PATCH 46/51] Input: atmel_mxt_ts - Initialize power config before and after downloading cfg Nick Dyer
2013-06-27 12:49 ` [PATCH 47/51] Input: atmel_mxt_ts - Add regulator control support Nick Dyer
2013-06-27 12:49 ` [PATCH 48/51] Input: atmel_mxt_ts - Implement support for T100 touch object Nick Dyer
2013-06-27 12:49 ` [PATCH 49/51] Input: atmel_mxt_ts - Allow specification of firmware file name Nick Dyer
2013-06-27 12:49 ` Nick Dyer [this message]
2013-06-27 12:49 ` [PATCH 51/51] Input: atmel_mxt_ts - Only use first T9 instance Nick Dyer
2013-06-27 15:17 ` Atmel updates to atmel_mxt_ts touch controller driver - v6 Nick Dyer
2013-07-18 19:47 ` rydberg
2013-08-15 15:55 ` Nick Dyer
2013-08-15 16:07 ` Dmitry Torokhov
2013-08-19 14:24 ` Nick Dyer
2013-09-10 13:58 ` Nick Dyer
[not found] ` <CAPDwgkOo7FYLujk16kJM=BqmXRKvZ2S_LOYURW0cXT5t=cmi6w@mail.gmail.com>
2014-01-15 10:44 ` Nick Dyer
[not found] ` <CAPDwgkOsP4K7r0-Mo-U52X9knRbGgbuD4dGptmj3x-LMTN75BA@mail.gmail.com>
2014-01-17 20:01 ` Nick Dyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1372337366-9286-51-git-send-email-nick.dyer@itdev.co.uk \
--to=nick.dyer@itdev.co.uk \
--cc=Alan.Bowens@atmel.com \
--cc=bleung@chromium.org \
--cc=djkurtz@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jy0922.shim@samsung.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=olofj@chromium.org \
--cc=pmeerw@pmeerw.net \
--cc=rydberg@euromail.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).