* [PATCH 1/2] input: touchscreen: atmel_mxt_ts: Add support for voltage regulator
2013-04-04 16:14 [PATCH 0/2] input: touchscreen: atmel_mxt_ts: Add Device Tree support Tomasz Figa
@ 2013-04-04 16:14 ` Tomasz Figa
2013-04-04 16:14 ` [PATCH 2/2] input: touchscreen: atmel_mxt_ts: Add support for Device Tree Tomasz Figa
2013-04-04 17:30 ` [PATCH 0/2] input: touchscreen: atmel_mxt_ts: Add Device Tree support Dmitry Torokhov
2 siblings, 0 replies; 5+ messages in thread
From: Tomasz Figa @ 2013-04-04 16:14 UTC (permalink / raw)
To: linux-input
Cc: devicetree-discuss, linux-samsung-soc, dmitry.torokhov,
jy0922.shim, kyungmin.park, Tomasz Figa
This patch removes the voltage field from platform data of the
atmel_mxt_ts driver and replaces it with regulator support.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
arch/arm/mach-exynos/mach-nuri.c | 29 ++++++++++++++++++++++++++++-
arch/arm/mach-exynos/mach-universal_c210.c | 29 ++++++++++++++++++++++++++++-
arch/arm/mach-s5pv210/mach-goni.c | 28 +++++++++++++++++++++++++++-
drivers/input/touchscreen/atmel_mxt_ts.c | 25 ++++++++++++++++++++-----
include/linux/i2c/atmel_mxt_ts.h | 1 -
5 files changed, 103 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index 1ea7973..98be36c 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -77,6 +77,7 @@ enum fixed_regulator_id {
FIXED_REG_ID_CAM_A28V,
FIXED_REG_ID_CAM_12V,
FIXED_REG_ID_CAM_VT_15V,
+ FIXED_REG_ID_TSP_2_8V,
};
static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
@@ -332,6 +333,32 @@ static struct i2c_board_info i2c1_devs[] __initdata = {
};
/* TSP */
+static struct regulator_consumer_supply tsp_fixed_consumer =
+ REGULATOR_SUPPLY("vdd", "3-004a");
+
+static struct regulator_init_data tsp_fixed_voltage_init_data = {
+ .constraints = {
+ .name = "TSP_2.8V",
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &tsp_fixed_consumer,
+};
+
+static struct fixed_voltage_config tsp_fixed_voltage_config = {
+ .supply_name = "TSP_VDD",
+ .microvolts = 2800000,
+ .gpio = -EINVAL,
+ .init_data = &tsp_fixed_voltage_init_data,
+};
+
+static struct platform_device tsp_fixed_voltage = {
+ .name = "reg-fixed-voltage",
+ .id = FIXED_REG_ID_TSP_2_8V,
+ .dev = {
+ .platform_data = &tsp_fixed_voltage_config,
+ },
+};
+
static struct mxt_platform_data mxt_platform_data = {
.x_line = 18,
.y_line = 11,
@@ -339,7 +366,6 @@ static struct mxt_platform_data mxt_platform_data = {
.y_size = 600,
.blen = 0x1,
.threshold = 0x28,
- .voltage = 2800000, /* 2.8V */
.orient = MXT_DIAGONAL_COUNTER,
.irqflags = IRQF_TRIGGER_FALLING,
};
@@ -1303,6 +1329,7 @@ static struct platform_device *nuri_devices[] __initdata = {
&s3c_device_wdt,
&s3c_device_timer[0],
&s5p_device_ehci,
+ &tsp_fixed_voltage,
&s3c_device_i2c3,
&i2c9_gpio,
&s3c_device_adc,
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c
index 497fcb7..2dbae3d 100644
--- a/arch/arm/mach-exynos/mach-universal_c210.c
+++ b/arch/arm/mach-exynos/mach-universal_c210.c
@@ -561,6 +561,7 @@ enum fixed_regulator_id {
FIXED_REG_ID_CAM_S_IF,
FIXED_REG_ID_CAM_I_CORE,
FIXED_REG_ID_CAM_VT_DIO,
+ FIXED_REG_ID_TSP_2_8V,
};
static struct regulator_consumer_supply hdmi_fixed_consumer =
@@ -603,6 +604,32 @@ static struct i2c_board_info i2c5_devs[] __initdata = {
};
/* I2C3 (TSP) */
+static struct regulator_consumer_supply tsp_fixed_consumer =
+ REGULATOR_SUPPLY("vdd", "3-004a");
+
+static struct regulator_init_data tsp_fixed_voltage_init_data = {
+ .constraints = {
+ .name = "TSP_2.8V",
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &tsp_fixed_consumer,
+};
+
+static struct fixed_voltage_config tsp_fixed_voltage_config = {
+ .supply_name = "TSP_VDD",
+ .microvolts = 2800000,
+ .gpio = -EINVAL,
+ .init_data = &tsp_fixed_voltage_init_data,
+};
+
+static struct platform_device tsp_fixed_voltage = {
+ .name = "reg-fixed-voltage",
+ .id = FIXED_REG_ID_TSP_2_8V,
+ .dev = {
+ .platform_data = &tsp_fixed_voltage_config,
+ },
+};
+
static struct mxt_platform_data qt602240_platform_data = {
.x_line = 19,
.y_line = 11,
@@ -610,7 +637,6 @@ static struct mxt_platform_data qt602240_platform_data = {
.y_size = 480,
.blen = 0x11,
.threshold = 0x28,
- .voltage = 2800000, /* 2.8V */
.orient = MXT_DIAGONAL,
.irqflags = IRQF_TRIGGER_FALLING,
};
@@ -1065,6 +1091,7 @@ static struct platform_device *universal_devices[] __initdata = {
&s3c_device_hsmmc2,
&s3c_device_hsmmc3,
&s3c_device_i2c0,
+ &tsp_fixed_voltage,
&s3c_device_i2c3,
&s3c_device_i2c5,
&s5p_device_i2c_hdmiphy,
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index 3a38f7b..71a38be 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -238,6 +238,32 @@ static void __init goni_radio_init(void)
}
/* TSP */
+static struct regulator_consumer_supply tsp_fixed_consumer =
+ REGULATOR_SUPPLY("vdd", "2-004a");
+
+static struct regulator_init_data tsp_fixed_voltage_init_data = {
+ .constraints = {
+ .name = "TSP_2.8V",
+ },
+ .num_consumer_supplies = 1,
+ .consumer_supplies = &tsp_fixed_consumer,
+};
+
+static struct fixed_voltage_config tsp_fixed_voltage_config = {
+ .supply_name = "TSP_VDD",
+ .microvolts = 2800000,
+ .gpio = -EINVAL,
+ .init_data = &tsp_fixed_voltage_init_data,
+};
+
+static struct platform_device tsp_fixed_voltage = {
+ .name = "reg-fixed-voltage",
+ .id = 3,
+ .dev = {
+ .platform_data = &tsp_fixed_voltage_config,
+ },
+};
+
static struct mxt_platform_data qt602240_platform_data = {
.x_line = 17,
.y_line = 11,
@@ -245,7 +271,6 @@ static struct mxt_platform_data qt602240_platform_data = {
.y_size = 480,
.blen = 0x21,
.threshold = 0x28,
- .voltage = 2800000, /* 2.8V */
.orient = MXT_DIAGONAL,
.irqflags = IRQF_TRIGGER_FALLING,
};
@@ -889,6 +914,7 @@ static struct platform_device *goni_devices[] __initdata = {
&s3c_device_usb_hsotg,
&samsung_device_keypad,
&s3c_device_i2c1,
+ &tsp_fixed_voltage,
&s3c_device_i2c2,
&wm8994_fixed_voltage0,
&wm8994_fixed_voltage1,
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 59aa240..de708ff 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -19,6 +19,7 @@
#include <linux/i2c/atmel_mxt_ts.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
+#include <linux/regulator/consumer.h>
#include <linux/slab.h>
/* Version */
@@ -247,6 +248,7 @@ struct mxt_message {
struct mxt_data {
struct i2c_client *client;
struct input_dev *input_dev;
+ struct regulator *regulator;
char phys[64]; /* device physical location */
const struct mxt_platform_data *pdata;
struct mxt_object *object_table;
@@ -720,13 +722,14 @@ static void mxt_handle_pdata(struct mxt_data *data)
MXT_TOUCH_YRANGE_MSB, (pdata->y_size - 1) >> 8);
/* Set touchscreen voltage */
- if (pdata->voltage) {
- if (pdata->voltage < MXT_VOLTAGE_DEFAULT) {
- voltage = (MXT_VOLTAGE_DEFAULT - pdata->voltage) /
+ if (!IS_ERR(data->regulator)) {
+ int reg_voltage = regulator_get_voltage(data->regulator);
+ if (reg_voltage < MXT_VOLTAGE_DEFAULT) {
+ voltage = (MXT_VOLTAGE_DEFAULT - reg_voltage) /
MXT_VOLTAGE_STEP;
voltage = 0xff - voltage + 1;
} else
- voltage = (pdata->voltage - MXT_VOLTAGE_DEFAULT) /
+ voltage = (reg_voltage - MXT_VOLTAGE_DEFAULT) /
MXT_VOLTAGE_STEP;
mxt_write_object(data, MXT_SPT_CTECONFIG_T28,
@@ -1151,6 +1154,13 @@ static int mxt_probe(struct i2c_client *client,
input_dev->name = (data->is_tp) ? "Atmel maXTouch Touchpad" :
"Atmel maXTouch Touchscreen";
+
+ data->regulator = devm_regulator_get(&client->dev, "vdd");
+ if (!IS_ERR(data->regulator)) {
+ regulator_enable(data->regulator);
+ msleep(100);
+ }
+
snprintf(data->phys, sizeof(data->phys), "i2c-%u-%04x/input0",
client->adapter->nr, client->addr);
@@ -1170,7 +1180,7 @@ static int mxt_probe(struct i2c_client *client,
error = mxt_initialize(data);
if (error)
- goto err_free_mem;
+ goto err_disable_regulator;
__set_bit(EV_ABS, input_dev->evbit);
__set_bit(EV_KEY, input_dev->evbit);
@@ -1253,6 +1263,9 @@ err_free_irq:
free_irq(client->irq, data);
err_free_object:
kfree(data->object_table);
+err_disable_regulator:
+ if (!IS_ERR(data->regulator))
+ regulator_disable(data->regulator);
err_free_mem:
input_free_device(input_dev);
kfree(data);
@@ -1267,6 +1280,8 @@ static int mxt_remove(struct i2c_client *client)
free_irq(data->irq, data);
input_unregister_device(data->input_dev);
kfree(data->object_table);
+ if (!IS_ERR(data->regulator))
+ regulator_disable(data->regulator);
kfree(data);
return 0;
diff --git a/include/linux/i2c/atmel_mxt_ts.h b/include/linux/i2c/atmel_mxt_ts.h
index 99e379b..03cb0c7 100644
--- a/include/linux/i2c/atmel_mxt_ts.h
+++ b/include/linux/i2c/atmel_mxt_ts.h
@@ -39,7 +39,6 @@ struct mxt_platform_data {
unsigned int y_size;
unsigned int blen;
unsigned int threshold;
- unsigned int voltage;
unsigned char orient;
unsigned long irqflags;
bool is_tp;
--
1.8.1.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] input: touchscreen: atmel_mxt_ts: Add support for Device Tree
2013-04-04 16:14 [PATCH 0/2] input: touchscreen: atmel_mxt_ts: Add Device Tree support Tomasz Figa
2013-04-04 16:14 ` [PATCH 1/2] input: touchscreen: atmel_mxt_ts: Add support for voltage regulator Tomasz Figa
@ 2013-04-04 16:14 ` Tomasz Figa
2013-04-04 17:30 ` [PATCH 0/2] input: touchscreen: atmel_mxt_ts: Add Device Tree support Dmitry Torokhov
2 siblings, 0 replies; 5+ messages in thread
From: Tomasz Figa @ 2013-04-04 16:14 UTC (permalink / raw)
To: linux-input
Cc: devicetree-discuss, linux-samsung-soc, dmitry.torokhov,
jy0922.shim, kyungmin.park, Tomasz Figa
This patch adds support for Device Tree-based instantation to the
atmel_mxt_ts driver.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
.../bindings/input/touchscreen/atmel_mxt_ts.txt | 51 +++++++++++++++
drivers/input/touchscreen/atmel_mxt_ts.c | 72 ++++++++++++++++++++++
2 files changed, 123 insertions(+)
create mode 100644 Documentation/devicetree/bindings/input/touchscreen/atmel_mxt_ts.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/atmel_mxt_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/atmel_mxt_ts.txt
new file mode 100644
index 0000000..d3149e1
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/atmel_mxt_ts.txt
@@ -0,0 +1,51 @@
+* Atmel maXtouch touchscreen controller
+
+Required properties:
+- compatible: must be "atmel,maxtouch"
+- reg: I2C address of the chip
+- interrupt-parent: interrupt controller which provides the interrupt
+- interrupts: interrupt signal to which the chip is connected
+- atmel,x-line: horizonal line
+- atmel,y-line: vertical line
+- atmel,x-size: horizontal resolution of touchscreen
+- atmel,y-size: vertical resolution of touchscreen
+- atmel,burst-length: burst length
+- atmel,threshold: threshold
+- atmel,orientation: touchscreen orientation, must be one of following:
+ - 0: normal
+ - 1: diagonal
+ - 2: horizonally flipped
+ - 3: rotated by 90 degrees counter-clockwise
+ - 4: vertically flipped
+ - 5: rotated by 90 degress clockwise
+ - 6: rotated by 180 degrees
+ - 7: diagonal counter
+
+Optional properties:
+- vdd-supply: voltage regulator used for power control and reading
+ operating voltage
+
+Example:
+
+ i2c@00000000 {
+ /* ... */
+
+ tsp@4a {
+ compatible = "atmel,maxtouch";
+ reg = <0x4a>;
+ interrupt-parent = <&gpe1>;
+ interrupts = <7 2>;
+
+ atmel,x-line = <19>;
+ atmel,y-line = <11>;
+ atmel,x-size = <800>;
+ atmel,y-size = <480>;
+ atmel,burst-length = <0x11>;
+ atmel,threshold = <0x28>;
+ atmel,orientation = <1>;
+
+ vdd-supply = <&tsp_reg>;
+ };
+
+ /* ... */
+ };
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index de708ff..611ac6f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1130,6 +1130,74 @@ static void mxt_input_close(struct input_dev *dev)
mxt_stop(data);
}
+#ifdef CONFIG_OF
+static struct of_device_id mxt_dt_match[] = {
+ { .compatible = "atmel,maxtouch" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, mxt_dt_match);
+
+static struct mxt_platform_data *mxt_parse_dt(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ struct mxt_platform_data *pd;
+ u32 val;
+
+ pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd) {
+ dev_err(dev, "Failed to allocate platform data\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,x-line", &pd->x_line)) {
+ dev_err(dev, "failed to get atmel,x-line property\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,y-line", &pd->y_line)) {
+ dev_err(dev, "failed to get atmel,y-line property\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,x-size", &pd->x_size)) {
+ dev_err(dev, "failed to get atmel,x-size property\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,y-size", &pd->y_size)) {
+ dev_err(dev, "failed to get atmel,y-size property\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,burst-length", &pd->blen)) {
+ dev_err(dev, "failed to get atmel,burst-length property\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,threshold", &pd->threshold)) {
+ dev_err(dev, "failed to get atmel,threshold property\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(np, "atmel,orientation", &val)) {
+ dev_err(dev, "failed to get atmel,orientation property\n");
+ return NULL;
+ }
+ if (val > MXT_DIAGONAL_COUNTER) {
+ dev_err(dev, "invalid value for atmel-orientation property\n");
+ return NULL;
+ }
+ pd->orient = val;
+
+ return pd;
+}
+#else
+static struct mxt_platform_data *mxt_parse_dt(struct device *dev)
+{
+ return NULL;
+}
+#endif
+
static int mxt_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1139,6 +1207,9 @@ static int mxt_probe(struct i2c_client *client,
int error;
unsigned int num_mt_slots;
+ if (!pdata && client->dev.of_node)
+ pdata = mxt_parse_dt(&client->dev);
+
if (!pdata)
return -EINVAL;
@@ -1343,6 +1414,7 @@ static struct i2c_driver mxt_driver = {
.name = "atmel_mxt_ts",
.owner = THIS_MODULE,
.pm = &mxt_pm_ops,
+ .of_match_table = of_match_ptr(mxt_dt_match),
},
.probe = mxt_probe,
.remove = mxt_remove,
--
1.8.1.5
^ permalink raw reply related [flat|nested] 5+ messages in thread