diff options
author | Luwei Zhou <b45643@freescale.com> | 2014-03-31 02:31:23 -0400 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-16 09:58:12 -0400 |
commit | c9b8d2d177ba94c0df02a2fda68c647f193589a1 (patch) | |
tree | d80968ff64520be03e93fdcd54325cb203632313 | |
parent | bd6cea40137510e96564863d6065a01c9f430240 (diff) |
ENGR00306133-1: input: misc: isl29023: Enable isl29023 driver for i.MX6SX-SDB platform
The isl29023 share the same interrupt gpio with mag3110 sensor. This patch add shared
interrutp support.
Signed-off-by: Luwei Zhou <b45643@freescale.com>
-rwxr-xr-x | drivers/input/misc/isl29023.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/input/misc/isl29023.c b/drivers/input/misc/isl29023.c index 9bcea5e3dd3f..3b3c7a0d931d 100755 --- a/drivers/input/misc/isl29023.c +++ b/drivers/input/misc/isl29023.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. | 2 | * Copyright (C) 2011-2014 Freescale Semiconductor, Inc. All Rights Reserved. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /* | 5 | /* |
@@ -582,6 +582,8 @@ static ssize_t isl29023_store_mode(struct device *dev, | |||
582 | (val > ISL29023_IR_CONT_MODE)) | 582 | (val > ISL29023_IR_CONT_MODE)) |
583 | return -EINVAL; | 583 | return -EINVAL; |
584 | 584 | ||
585 | /* clear the interrupt flag */ | ||
586 | i2c_smbus_read_byte_data(client, ISL29023_COMMAND1); | ||
585 | ret = isl29023_set_mode(client, val); | 587 | ret = isl29023_set_mode(client, val); |
586 | if (ret < 0) | 588 | if (ret < 0) |
587 | return ret; | 589 | return ret; |
@@ -844,6 +846,11 @@ static void isl29023_work(struct work_struct *work) | |||
844 | static irqreturn_t isl29023_irq_handler(int irq, void *handle) | 846 | static irqreturn_t isl29023_irq_handler(int irq, void *handle) |
845 | { | 847 | { |
846 | struct isl29023_data *data = handle; | 848 | struct isl29023_data *data = handle; |
849 | int cmd_1; | ||
850 | cmd_1 = i2c_smbus_read_byte_data(data->client, ISL29023_COMMAND1); | ||
851 | if (!(cmd_1 & ISL29023_INT_FLAG_MASK)) | ||
852 | return IRQ_NONE; | ||
853 | |||
847 | queue_work(data->workqueue, &data->work); | 854 | queue_work(data->workqueue, &data->work); |
848 | return IRQ_HANDLED; | 855 | return IRQ_HANDLED; |
849 | } | 856 | } |
@@ -862,6 +869,9 @@ static int isl29023_probe(struct i2c_client *client, | |||
862 | struct regulator *vdd = NULL; | 869 | struct regulator *vdd = NULL; |
863 | u32 rext = 0; | 870 | u32 rext = 0; |
864 | struct device_node *of_node = client->dev.of_node; | 871 | struct device_node *of_node = client->dev.of_node; |
872 | struct irq_data *irq_data = irq_get_irq_data(client->irq); | ||
873 | u32 irq_flag; | ||
874 | bool shared_irq; | ||
865 | 875 | ||
866 | vdd = devm_regulator_get(&client->dev, "vdd"); | 876 | vdd = devm_regulator_get(&client->dev, "vdd"); |
867 | if (!IS_ERR(vdd)) { | 877 | if (!IS_ERR(vdd)) { |
@@ -875,6 +885,7 @@ static int isl29023_probe(struct i2c_client *client, | |||
875 | err = of_property_read_u32(of_node, "rext", &rext); | 885 | err = of_property_read_u32(of_node, "rext", &rext); |
876 | if (err) | 886 | if (err) |
877 | rext = DEFAULT_REGISTOR_VAL; | 887 | rext = DEFAULT_REGISTOR_VAL; |
888 | shared_irq = of_property_read_bool(of_node, "shared-interrupt"); | ||
878 | 889 | ||
879 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) | 890 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) |
880 | return -EIO; | 891 | return -EIO; |
@@ -919,10 +930,13 @@ static int isl29023_probe(struct i2c_client *client, | |||
919 | if (err) | 930 | if (err) |
920 | goto exit_free_input; | 931 | goto exit_free_input; |
921 | 932 | ||
922 | /* set irq type to edge falling */ | 933 | irq_flag = irqd_get_trigger_type(irq_data); |
923 | irq_set_irq_type(client->irq, IRQF_TRIGGER_FALLING); | 934 | irq_flag |= IRQF_ONESHOT; |
924 | err = request_irq(client->irq, isl29023_irq_handler, 0, | 935 | if (shared_irq) |
925 | client->dev.driver->name, data); | 936 | irq_flag |= IRQF_SHARED; |
937 | err = request_threaded_irq(client->irq, NULL, | ||
938 | isl29023_irq_handler, irq_flag, | ||
939 | client->dev.driver->name, data); | ||
926 | if (err < 0) { | 940 | if (err < 0) { |
927 | dev_err(&client->dev, "failed to register irq %d!\n", | 941 | dev_err(&client->dev, "failed to register irq %d!\n", |
928 | client->irq); | 942 | client->irq); |