diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-05-22 02:36:56 -0400 |
commit | cf9b59e9d3e008591d1f54830f570982bb307a0d (patch) | |
tree | 113478ce8fd8c832ba726ffdf59b82cb46356476 /drivers/input/misc/ad714x-spi.c | |
parent | 44504b2bebf8b5823c59484e73096a7d6574471d (diff) | |
parent | f4b87dee923342505e1ddba8d34ce9de33e75050 (diff) |
Merge remote branch 'origin' into secretlab/next-devicetree
Merging in current state of Linus' tree to deal with merge conflicts and
build failures in vio.c after merge.
Conflicts:
drivers/i2c/busses/i2c-cpm.c
drivers/i2c/busses/i2c-mpc.c
drivers/net/gianfar.c
Also fixed up one line in arch/powerpc/kernel/vio.c to use the
correct node pointer.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/input/misc/ad714x-spi.c')
-rw-r--r-- | drivers/input/misc/ad714x-spi.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/drivers/input/misc/ad714x-spi.c b/drivers/input/misc/ad714x-spi.c new file mode 100644 index 000000000000..7f8dedfd1bfe --- /dev/null +++ b/drivers/input/misc/ad714x-spi.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /* | ||
2 | * AD714X CapTouch Programmable Controller driver (SPI bus) | ||
3 | * | ||
4 | * Copyright 2009 Analog Devices Inc. | ||
5 | * | ||
6 | * Licensed under the GPL-2 or later. | ||
7 | */ | ||
8 | |||
9 | #include <linux/input.h> /* BUS_I2C */ | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/spi/spi.h> | ||
12 | #include <linux/types.h> | ||
13 | #include "ad714x.h" | ||
14 | |||
15 | #define AD714x_SPI_CMD_PREFIX 0xE000 /* bits 15:11 */ | ||
16 | #define AD714x_SPI_READ BIT(10) | ||
17 | |||
18 | #ifdef CONFIG_PM | ||
19 | static int ad714x_spi_suspend(struct spi_device *spi, pm_message_t message) | ||
20 | { | ||
21 | return ad714x_disable(spi_get_drvdata(spi)); | ||
22 | } | ||
23 | |||
24 | static int ad714x_spi_resume(struct spi_device *spi) | ||
25 | { | ||
26 | return ad714x_enable(spi_get_drvdata(spi)); | ||
27 | } | ||
28 | #else | ||
29 | # define ad714x_spi_suspend NULL | ||
30 | # define ad714x_spi_resume NULL | ||
31 | #endif | ||
32 | |||
33 | static int ad714x_spi_read(struct device *dev, unsigned short reg, | ||
34 | unsigned short *data) | ||
35 | { | ||
36 | struct spi_device *spi = to_spi_device(dev); | ||
37 | unsigned short tx = AD714x_SPI_CMD_PREFIX | AD714x_SPI_READ | reg; | ||
38 | |||
39 | return spi_write_then_read(spi, (u8 *)&tx, 2, (u8 *)data, 2); | ||
40 | } | ||
41 | |||
42 | static int ad714x_spi_write(struct device *dev, unsigned short reg, | ||
43 | unsigned short data) | ||
44 | { | ||
45 | struct spi_device *spi = to_spi_device(dev); | ||
46 | unsigned short tx[2] = { | ||
47 | AD714x_SPI_CMD_PREFIX | reg, | ||
48 | data | ||
49 | }; | ||
50 | |||
51 | return spi_write(spi, (u8 *)tx, 4); | ||
52 | } | ||
53 | |||
54 | static int __devinit ad714x_spi_probe(struct spi_device *spi) | ||
55 | { | ||
56 | struct ad714x_chip *chip; | ||
57 | |||
58 | chip = ad714x_probe(&spi->dev, BUS_SPI, spi->irq, | ||
59 | ad714x_spi_read, ad714x_spi_write); | ||
60 | if (IS_ERR(chip)) | ||
61 | return PTR_ERR(chip); | ||
62 | |||
63 | spi_set_drvdata(spi, chip); | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static int __devexit ad714x_spi_remove(struct spi_device *spi) | ||
69 | { | ||
70 | struct ad714x_chip *chip = spi_get_drvdata(spi); | ||
71 | |||
72 | ad714x_remove(chip); | ||
73 | spi_set_drvdata(spi, NULL); | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static struct spi_driver ad714x_spi_driver = { | ||
79 | .driver = { | ||
80 | .name = "ad714x_captouch", | ||
81 | .owner = THIS_MODULE, | ||
82 | }, | ||
83 | .probe = ad714x_spi_probe, | ||
84 | .remove = __devexit_p(ad714x_spi_remove), | ||
85 | .suspend = ad714x_spi_suspend, | ||
86 | .resume = ad714x_spi_resume, | ||
87 | }; | ||
88 | |||
89 | static __init int ad714x_spi_init(void) | ||
90 | { | ||
91 | return spi_register_driver(&ad714x_spi_driver); | ||
92 | } | ||
93 | module_init(ad714x_spi_init); | ||
94 | |||
95 | static __exit void ad714x_spi_exit(void) | ||
96 | { | ||
97 | spi_unregister_driver(&ad714x_spi_driver); | ||
98 | } | ||
99 | module_exit(ad714x_spi_exit); | ||
100 | |||
101 | MODULE_DESCRIPTION("Analog Devices AD714X Capacitance Touch Sensor SPI Bus Driver"); | ||
102 | MODULE_AUTHOR("Barry Song <21cnbao@gmail.com>"); | ||
103 | MODULE_LICENSE("GPL"); | ||