Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 1 | /* |
| 2 | * TI Touch Screen / ADC MFD driver |
| 3 | * |
| 4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation version 2. |
| 9 | * |
| 10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any |
| 11 | * kind, whether express or implied; without even the implied warranty |
| 12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #include <linux/module.h> |
| 17 | #include <linux/init.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/err.h> |
| 20 | #include <linux/io.h> |
| 21 | #include <linux/clk.h> |
| 22 | #include <linux/regmap.h> |
| 23 | #include <linux/mfd/core.h> |
| 24 | #include <linux/pm_runtime.h> |
Patil, Rachna | a6543a1 | 2013-01-24 03:45:09 +0000 | [diff] [blame] | 25 | #include <linux/of.h> |
| 26 | #include <linux/of_device.h> |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 27 | |
| 28 | #include <linux/mfd/ti_am335x_tscadc.h> |
| 29 | |
| 30 | static unsigned int tscadc_readl(struct ti_tscadc_dev *tsadc, unsigned int reg) |
| 31 | { |
| 32 | unsigned int val; |
| 33 | |
| 34 | regmap_read(tsadc->regmap_tscadc, reg, &val); |
| 35 | return val; |
| 36 | } |
| 37 | |
| 38 | static void tscadc_writel(struct ti_tscadc_dev *tsadc, unsigned int reg, |
| 39 | unsigned int val) |
| 40 | { |
| 41 | regmap_write(tsadc->regmap_tscadc, reg, val); |
| 42 | } |
| 43 | |
| 44 | static const struct regmap_config tscadc_regmap_config = { |
| 45 | .name = "ti_tscadc", |
| 46 | .reg_bits = 32, |
| 47 | .reg_stride = 4, |
| 48 | .val_bits = 32, |
| 49 | }; |
| 50 | |
Sebastian Andrzej Siewior | 3466bd2 | 2013-12-19 16:28:28 +0100 | [diff] [blame] | 51 | static void am335x_tsc_se_update(struct ti_tscadc_dev *tsadc) |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 52 | { |
| 53 | tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache); |
| 54 | } |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 55 | |
Sebastian Andrzej Siewior | 7e170c6 | 2013-12-19 16:28:29 +0100 | [diff] [blame^] | 56 | void am335x_tsc_se_set_cache(struct ti_tscadc_dev *tsadc, u32 val) |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 57 | { |
Sebastian Andrzej Siewior | 317b209 | 2013-10-22 16:12:39 +0200 | [diff] [blame] | 58 | unsigned long flags; |
| 59 | |
| 60 | spin_lock_irqsave(&tsadc->reg_lock, flags); |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 61 | tsadc->reg_se_cache |= val; |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 62 | am335x_tsc_se_update(tsadc); |
Sebastian Andrzej Siewior | 317b209 | 2013-10-22 16:12:39 +0200 | [diff] [blame] | 63 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 64 | } |
Sebastian Andrzej Siewior | 7e170c6 | 2013-12-19 16:28:29 +0100 | [diff] [blame^] | 65 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set_cache); |
| 66 | |
| 67 | void am335x_tsc_se_set_once(struct ti_tscadc_dev *tsadc, u32 val) |
| 68 | { |
| 69 | unsigned long flags; |
| 70 | |
| 71 | spin_lock_irqsave(&tsadc->reg_lock, flags); |
| 72 | tscadc_writel(tsadc, REG_SE, tsadc->reg_se_cache | val); |
| 73 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); |
| 74 | } |
| 75 | EXPORT_SYMBOL_GPL(am335x_tsc_se_set_once); |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 76 | |
| 77 | void am335x_tsc_se_clr(struct ti_tscadc_dev *tsadc, u32 val) |
| 78 | { |
Sebastian Andrzej Siewior | 317b209 | 2013-10-22 16:12:39 +0200 | [diff] [blame] | 79 | unsigned long flags; |
| 80 | |
| 81 | spin_lock_irqsave(&tsadc->reg_lock, flags); |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 82 | tsadc->reg_se_cache &= ~val; |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 83 | am335x_tsc_se_update(tsadc); |
Sebastian Andrzej Siewior | 317b209 | 2013-10-22 16:12:39 +0200 | [diff] [blame] | 84 | spin_unlock_irqrestore(&tsadc->reg_lock, flags); |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 85 | } |
| 86 | EXPORT_SYMBOL_GPL(am335x_tsc_se_clr); |
| 87 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 88 | static void tscadc_idle_config(struct ti_tscadc_dev *config) |
| 89 | { |
| 90 | unsigned int idleconfig; |
| 91 | |
| 92 | idleconfig = STEPCONFIG_YNN | STEPCONFIG_INM_ADCREFM | |
| 93 | STEPCONFIG_INP_ADCREFM | STEPCONFIG_YPN; |
| 94 | |
| 95 | tscadc_writel(config, REG_IDLECONFIG, idleconfig); |
| 96 | } |
| 97 | |
Greg Kroah-Hartman | 612b95c | 2012-12-21 15:03:15 -0800 | [diff] [blame] | 98 | static int ti_tscadc_probe(struct platform_device *pdev) |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 99 | { |
| 100 | struct ti_tscadc_dev *tscadc; |
| 101 | struct resource *res; |
| 102 | struct clk *clk; |
Patil, Rachna | a6543a1 | 2013-01-24 03:45:09 +0000 | [diff] [blame] | 103 | struct device_node *node = pdev->dev.of_node; |
Patil, Rachna | 2b99baf | 2012-10-16 12:55:44 +0530 | [diff] [blame] | 104 | struct mfd_cell *cell; |
Sebastian Andrzej Siewior | 18926ed | 2013-05-29 17:39:02 +0200 | [diff] [blame] | 105 | struct property *prop; |
| 106 | const __be32 *cur; |
| 107 | u32 val; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 108 | int err, ctrl; |
Matthias Kaehlcke | e90f875 | 2013-09-23 22:43:29 +0200 | [diff] [blame] | 109 | int clock_rate; |
Patil, Rachna | a6543a1 | 2013-01-24 03:45:09 +0000 | [diff] [blame] | 110 | int tsc_wires = 0, adc_channels = 0, total_channels; |
Sebastian Andrzej Siewior | 18926ed | 2013-05-29 17:39:02 +0200 | [diff] [blame] | 111 | int readouts = 0; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 112 | |
Sebastian Andrzej Siewior | 9e5775f | 2013-05-21 17:56:49 +0200 | [diff] [blame] | 113 | if (!pdev->dev.of_node) { |
| 114 | dev_err(&pdev->dev, "Could not find valid DT data.\n"); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 115 | return -EINVAL; |
| 116 | } |
| 117 | |
Sebastian Andrzej Siewior | 9e5775f | 2013-05-21 17:56:49 +0200 | [diff] [blame] | 118 | node = of_get_child_by_name(pdev->dev.of_node, "tsc"); |
| 119 | of_property_read_u32(node, "ti,wires", &tsc_wires); |
Sebastian Andrzej Siewior | 18926ed | 2013-05-29 17:39:02 +0200 | [diff] [blame] | 120 | of_property_read_u32(node, "ti,coordiante-readouts", &readouts); |
Patil, Rachna | 5e53a69 | 2012-10-16 12:55:45 +0530 | [diff] [blame] | 121 | |
Sebastian Andrzej Siewior | 9e5775f | 2013-05-21 17:56:49 +0200 | [diff] [blame] | 122 | node = of_get_child_by_name(pdev->dev.of_node, "adc"); |
Sebastian Andrzej Siewior | 18926ed | 2013-05-29 17:39:02 +0200 | [diff] [blame] | 123 | of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) { |
| 124 | adc_channels++; |
| 125 | if (val > 7) { |
| 126 | dev_err(&pdev->dev, " PIN numbers are 0..7 (not %d)\n", |
| 127 | val); |
| 128 | return -EINVAL; |
| 129 | } |
| 130 | } |
Patil, Rachna | 5e53a69 | 2012-10-16 12:55:45 +0530 | [diff] [blame] | 131 | total_channels = tsc_wires + adc_channels; |
Patil, Rachna | 5e53a69 | 2012-10-16 12:55:45 +0530 | [diff] [blame] | 132 | if (total_channels > 8) { |
| 133 | dev_err(&pdev->dev, "Number of i/p channels more than 8\n"); |
| 134 | return -EINVAL; |
| 135 | } |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 136 | if (total_channels == 0) { |
| 137 | dev_err(&pdev->dev, "Need atleast one channel.\n"); |
| 138 | return -EINVAL; |
| 139 | } |
Patil, Rachna | 2b99baf | 2012-10-16 12:55:44 +0530 | [diff] [blame] | 140 | |
Sebastian Andrzej Siewior | 18926ed | 2013-05-29 17:39:02 +0200 | [diff] [blame] | 141 | if (readouts * 2 + 2 + adc_channels > 16) { |
| 142 | dev_err(&pdev->dev, "Too many step configurations requested\n"); |
| 143 | return -EINVAL; |
| 144 | } |
| 145 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 146 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 147 | if (!res) { |
| 148 | dev_err(&pdev->dev, "no memory resource defined.\n"); |
| 149 | return -EINVAL; |
| 150 | } |
| 151 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 152 | /* Allocate memory for device */ |
| 153 | tscadc = devm_kzalloc(&pdev->dev, |
| 154 | sizeof(struct ti_tscadc_dev), GFP_KERNEL); |
| 155 | if (!tscadc) { |
| 156 | dev_err(&pdev->dev, "failed to allocate memory.\n"); |
| 157 | return -ENOMEM; |
| 158 | } |
| 159 | tscadc->dev = &pdev->dev; |
Patil, Rachna | 3c39c9c | 2012-11-06 13:39:03 +0530 | [diff] [blame] | 160 | |
| 161 | err = platform_get_irq(pdev, 0); |
| 162 | if (err < 0) { |
| 163 | dev_err(&pdev->dev, "no irq ID is specified.\n"); |
| 164 | goto ret; |
| 165 | } else |
| 166 | tscadc->irq = err; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 167 | |
| 168 | res = devm_request_mem_region(&pdev->dev, |
| 169 | res->start, resource_size(res), pdev->name); |
| 170 | if (!res) { |
| 171 | dev_err(&pdev->dev, "failed to reserve registers.\n"); |
Patil, Rachna | 3c39c9c | 2012-11-06 13:39:03 +0530 | [diff] [blame] | 172 | return -EBUSY; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | tscadc->tscadc_base = devm_ioremap(&pdev->dev, |
| 176 | res->start, resource_size(res)); |
| 177 | if (!tscadc->tscadc_base) { |
| 178 | dev_err(&pdev->dev, "failed to map registers.\n"); |
Patil, Rachna | 3c39c9c | 2012-11-06 13:39:03 +0530 | [diff] [blame] | 179 | return -ENOMEM; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | tscadc->regmap_tscadc = devm_regmap_init_mmio(&pdev->dev, |
| 183 | tscadc->tscadc_base, &tscadc_regmap_config); |
| 184 | if (IS_ERR(tscadc->regmap_tscadc)) { |
| 185 | dev_err(&pdev->dev, "regmap init failed\n"); |
| 186 | err = PTR_ERR(tscadc->regmap_tscadc); |
Patil, Rachna | 3c39c9c | 2012-11-06 13:39:03 +0530 | [diff] [blame] | 187 | goto ret; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 188 | } |
| 189 | |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 190 | spin_lock_init(&tscadc->reg_lock); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 191 | pm_runtime_enable(&pdev->dev); |
| 192 | pm_runtime_get_sync(&pdev->dev); |
| 193 | |
| 194 | /* |
| 195 | * The TSC_ADC_Subsystem has 2 clock domains |
| 196 | * OCP_CLK and ADC_CLK. |
| 197 | * The ADC clock is expected to run at target of 3MHz, |
| 198 | * and expected to capture 12-bit data at a rate of 200 KSPS. |
| 199 | * The TSC_ADC_SS controller design assumes the OCP clock is |
| 200 | * at least 6x faster than the ADC clock. |
| 201 | */ |
| 202 | clk = clk_get(&pdev->dev, "adc_tsc_fck"); |
| 203 | if (IS_ERR(clk)) { |
| 204 | dev_err(&pdev->dev, "failed to get TSC fck\n"); |
| 205 | err = PTR_ERR(clk); |
| 206 | goto err_disable_clk; |
| 207 | } |
| 208 | clock_rate = clk_get_rate(clk); |
| 209 | clk_put(clk); |
Matthias Kaehlcke | e90f875 | 2013-09-23 22:43:29 +0200 | [diff] [blame] | 210 | tscadc->clk_div = clock_rate / ADC_CLK; |
Patil, Rachna | efe3126 | 2013-07-20 17:27:35 +0100 | [diff] [blame] | 211 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 212 | /* TSCADC_CLKDIV needs to be configured to the value minus 1 */ |
Matthias Kaehlcke | e90f875 | 2013-09-23 22:43:29 +0200 | [diff] [blame] | 213 | tscadc->clk_div--; |
| 214 | tscadc_writel(tscadc, REG_CLKDIV, tscadc->clk_div); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 215 | |
| 216 | /* Set the control register bits */ |
| 217 | ctrl = CNTRLREG_STEPCONFIGWRT | |
Patil, Rachna | b5f8b76 | 2013-07-20 17:27:34 +0100 | [diff] [blame] | 218 | CNTRLREG_STEPID; |
| 219 | if (tsc_wires > 0) |
| 220 | ctrl |= CNTRLREG_4WIRE | CNTRLREG_TSCENB; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 221 | tscadc_writel(tscadc, REG_CTRL, ctrl); |
| 222 | |
| 223 | /* Set register bits for Idle Config Mode */ |
Patil, Rachna | b5f8b76 | 2013-07-20 17:27:34 +0100 | [diff] [blame] | 224 | if (tsc_wires > 0) |
| 225 | tscadc_idle_config(tscadc); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 226 | |
| 227 | /* Enable the TSC module enable bit */ |
| 228 | ctrl = tscadc_readl(tscadc, REG_CTRL); |
| 229 | ctrl |= CNTRLREG_TSCSSENB; |
| 230 | tscadc_writel(tscadc, REG_CTRL, ctrl); |
| 231 | |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 232 | tscadc->used_cells = 0; |
| 233 | tscadc->tsc_cell = -1; |
| 234 | tscadc->adc_cell = -1; |
| 235 | |
Patil, Rachna | 2b99baf | 2012-10-16 12:55:44 +0530 | [diff] [blame] | 236 | /* TSC Cell */ |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 237 | if (tsc_wires > 0) { |
| 238 | tscadc->tsc_cell = tscadc->used_cells; |
| 239 | cell = &tscadc->cells[tscadc->used_cells++]; |
Sebastian Andrzej Siewior | 5f184e6 | 2013-05-27 17:08:28 +0200 | [diff] [blame] | 240 | cell->name = "TI-am335x-tsc"; |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 241 | cell->of_compatible = "ti,am3359-tsc"; |
| 242 | cell->platform_data = &tscadc; |
| 243 | cell->pdata_size = sizeof(tscadc); |
| 244 | } |
Patil, Rachna | 2b99baf | 2012-10-16 12:55:44 +0530 | [diff] [blame] | 245 | |
Patil, Rachna | 5e53a69 | 2012-10-16 12:55:45 +0530 | [diff] [blame] | 246 | /* ADC Cell */ |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 247 | if (adc_channels > 0) { |
| 248 | tscadc->adc_cell = tscadc->used_cells; |
| 249 | cell = &tscadc->cells[tscadc->used_cells++]; |
Sebastian Andrzej Siewior | 9f99928 | 2013-05-27 17:12:52 +0200 | [diff] [blame] | 250 | cell->name = "TI-am335x-adc"; |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 251 | cell->of_compatible = "ti,am3359-adc"; |
| 252 | cell->platform_data = &tscadc; |
| 253 | cell->pdata_size = sizeof(tscadc); |
| 254 | } |
Patil, Rachna | 5e53a69 | 2012-10-16 12:55:45 +0530 | [diff] [blame] | 255 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 256 | err = mfd_add_devices(&pdev->dev, pdev->id, tscadc->cells, |
Pantelis Antoniou | 24d5c82 | 2012-10-13 16:37:24 +0300 | [diff] [blame] | 257 | tscadc->used_cells, NULL, 0, NULL); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 258 | if (err < 0) |
| 259 | goto err_disable_clk; |
| 260 | |
| 261 | device_init_wakeup(&pdev->dev, true); |
| 262 | platform_set_drvdata(pdev, tscadc); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 263 | return 0; |
| 264 | |
| 265 | err_disable_clk: |
| 266 | pm_runtime_put_sync(&pdev->dev); |
| 267 | pm_runtime_disable(&pdev->dev); |
Patil, Rachna | 3c39c9c | 2012-11-06 13:39:03 +0530 | [diff] [blame] | 268 | ret: |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 269 | return err; |
| 270 | } |
| 271 | |
Greg Kroah-Hartman | 612b95c | 2012-12-21 15:03:15 -0800 | [diff] [blame] | 272 | static int ti_tscadc_remove(struct platform_device *pdev) |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 273 | { |
| 274 | struct ti_tscadc_dev *tscadc = platform_get_drvdata(pdev); |
| 275 | |
| 276 | tscadc_writel(tscadc, REG_SE, 0x00); |
| 277 | |
| 278 | pm_runtime_put_sync(&pdev->dev); |
| 279 | pm_runtime_disable(&pdev->dev); |
| 280 | |
| 281 | mfd_remove_devices(tscadc->dev); |
| 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | #ifdef CONFIG_PM |
| 287 | static int tscadc_suspend(struct device *dev) |
| 288 | { |
| 289 | struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev); |
| 290 | |
| 291 | tscadc_writel(tscadc_dev, REG_SE, 0x00); |
| 292 | pm_runtime_put_sync(dev); |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int tscadc_resume(struct device *dev) |
| 298 | { |
| 299 | struct ti_tscadc_dev *tscadc_dev = dev_get_drvdata(dev); |
| 300 | unsigned int restore, ctrl; |
| 301 | |
| 302 | pm_runtime_get_sync(dev); |
| 303 | |
| 304 | /* context restore */ |
Patil, Rachna | b5f8b76 | 2013-07-20 17:27:34 +0100 | [diff] [blame] | 305 | ctrl = CNTRLREG_STEPCONFIGWRT | CNTRLREG_STEPID; |
| 306 | if (tscadc_dev->tsc_cell != -1) |
| 307 | ctrl |= CNTRLREG_TSCENB | CNTRLREG_4WIRE; |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 308 | tscadc_writel(tscadc_dev, REG_CTRL, ctrl); |
Patil, Rachna | b5f8b76 | 2013-07-20 17:27:34 +0100 | [diff] [blame] | 309 | |
| 310 | if (tscadc_dev->tsc_cell != -1) |
| 311 | tscadc_idle_config(tscadc_dev); |
Patil, Rachna | abeccee | 2013-01-24 03:45:05 +0000 | [diff] [blame] | 312 | am335x_tsc_se_update(tscadc_dev); |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 313 | restore = tscadc_readl(tscadc_dev, REG_CTRL); |
| 314 | tscadc_writel(tscadc_dev, REG_CTRL, |
| 315 | (restore | CNTRLREG_TSCSSENB)); |
| 316 | |
Matthias Kaehlcke | e90f875 | 2013-09-23 22:43:29 +0200 | [diff] [blame] | 317 | tscadc_writel(tscadc_dev, REG_CLKDIV, tscadc_dev->clk_div); |
| 318 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 319 | return 0; |
| 320 | } |
| 321 | |
| 322 | static const struct dev_pm_ops tscadc_pm_ops = { |
| 323 | .suspend = tscadc_suspend, |
| 324 | .resume = tscadc_resume, |
| 325 | }; |
| 326 | #define TSCADC_PM_OPS (&tscadc_pm_ops) |
| 327 | #else |
| 328 | #define TSCADC_PM_OPS NULL |
| 329 | #endif |
| 330 | |
Patil, Rachna | a6543a1 | 2013-01-24 03:45:09 +0000 | [diff] [blame] | 331 | static const struct of_device_id ti_tscadc_dt_ids[] = { |
| 332 | { .compatible = "ti,am3359-tscadc", }, |
| 333 | { } |
| 334 | }; |
| 335 | MODULE_DEVICE_TABLE(of, ti_tscadc_dt_ids); |
| 336 | |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 337 | static struct platform_driver ti_tscadc_driver = { |
| 338 | .driver = { |
Patil, Rachna | a6543a1 | 2013-01-24 03:45:09 +0000 | [diff] [blame] | 339 | .name = "ti_am3359-tscadc", |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 340 | .owner = THIS_MODULE, |
| 341 | .pm = TSCADC_PM_OPS, |
Sachin Kamat | 131221b | 2013-10-15 09:18:49 +0530 | [diff] [blame] | 342 | .of_match_table = ti_tscadc_dt_ids, |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 343 | }, |
| 344 | .probe = ti_tscadc_probe, |
Greg Kroah-Hartman | 612b95c | 2012-12-21 15:03:15 -0800 | [diff] [blame] | 345 | .remove = ti_tscadc_remove, |
Patil, Rachna | 01636eb | 2012-10-16 12:55:43 +0530 | [diff] [blame] | 346 | |
| 347 | }; |
| 348 | |
| 349 | module_platform_driver(ti_tscadc_driver); |
| 350 | |
| 351 | MODULE_DESCRIPTION("TI touchscreen / ADC MFD controller driver"); |
| 352 | MODULE_AUTHOR("Rachna Patil <rachna@ti.com>"); |
| 353 | MODULE_LICENSE("GPL"); |