diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2014-04-08 20:14:15 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2014-06-03 03:11:23 -0400 |
commit | 3e87933a68dce6a27bf1006964f8c850e13140b5 (patch) | |
tree | e8f410d8e23a845f1f76eb8951a116959032d5d9 | |
parent | c4f725b52cde3b82d66d54201bc97fcd539bffc8 (diff) |
mfd: pm8921: Remove pm8xxx API now that sub-devices use regmap
The pm8xxx read/write wrappers are no longer necessary now that
all the sub-device drivers are using the regmap API. Remove it.
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | drivers/mfd/pm8921-core.c | 123 | ||||
-rw-r--r-- | include/linux/mfd/pm8xxx/core.h | 81 |
2 files changed, 2 insertions, 202 deletions
diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c index b97a97187ae9..959513803542 100644 --- a/drivers/mfd/pm8921-core.c +++ b/drivers/mfd/pm8921-core.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/regmap.h> | 26 | #include <linux/regmap.h> |
27 | #include <linux/of_platform.h> | 27 | #include <linux/of_platform.h> |
28 | #include <linux/mfd/core.h> | 28 | #include <linux/mfd/core.h> |
29 | #include <linux/mfd/pm8xxx/core.h> | ||
30 | 29 | ||
31 | #define SSBI_REG_ADDR_IRQ_BASE 0x1BB | 30 | #define SSBI_REG_ADDR_IRQ_BASE 0x1BB |
32 | 31 | ||
@@ -57,7 +56,6 @@ | |||
57 | #define PM8921_NR_IRQS 256 | 56 | #define PM8921_NR_IRQS 256 |
58 | 57 | ||
59 | struct pm_irq_chip { | 58 | struct pm_irq_chip { |
60 | struct device *dev; | ||
61 | struct regmap *regmap; | 59 | struct regmap *regmap; |
62 | spinlock_t pm_irq_lock; | 60 | spinlock_t pm_irq_lock; |
63 | struct irq_domain *irqdomain; | 61 | struct irq_domain *irqdomain; |
@@ -67,11 +65,6 @@ struct pm_irq_chip { | |||
67 | u8 config[0]; | 65 | u8 config[0]; |
68 | }; | 66 | }; |
69 | 67 | ||
70 | struct pm8921 { | ||
71 | struct device *dev; | ||
72 | struct pm_irq_chip *irq_chip; | ||
73 | }; | ||
74 | |||
75 | static int pm8xxx_read_block_irq(struct pm_irq_chip *chip, unsigned int bp, | 68 | static int pm8xxx_read_block_irq(struct pm_irq_chip *chip, unsigned int bp, |
76 | unsigned int *ip) | 69 | unsigned int *ip) |
77 | { | 70 | { |
@@ -255,55 +248,6 @@ static struct irq_chip pm8xxx_irq_chip = { | |||
255 | .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, | 248 | .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SKIP_SET_WAKE, |
256 | }; | 249 | }; |
257 | 250 | ||
258 | /** | ||
259 | * pm8xxx_get_irq_stat - get the status of the irq line | ||
260 | * @chip: pointer to identify a pmic irq controller | ||
261 | * @irq: the irq number | ||
262 | * | ||
263 | * The pm8xxx gpio and mpp rely on the interrupt block to read | ||
264 | * the values on their pins. This function is to facilitate reading | ||
265 | * the status of a gpio or an mpp line. The caller has to convert the | ||
266 | * gpio number to irq number. | ||
267 | * | ||
268 | * RETURNS: | ||
269 | * an int indicating the value read on that line | ||
270 | */ | ||
271 | static int pm8xxx_get_irq_stat(struct pm_irq_chip *chip, int irq) | ||
272 | { | ||
273 | int pmirq, rc; | ||
274 | unsigned int block, bits, bit; | ||
275 | unsigned long flags; | ||
276 | struct irq_data *irq_data = irq_get_irq_data(irq); | ||
277 | |||
278 | pmirq = irq_data->hwirq; | ||
279 | |||
280 | block = pmirq / 8; | ||
281 | bit = pmirq % 8; | ||
282 | |||
283 | spin_lock_irqsave(&chip->pm_irq_lock, flags); | ||
284 | |||
285 | rc = regmap_write(chip->regmap, SSBI_REG_ADDR_IRQ_BLK_SEL, block); | ||
286 | if (rc) { | ||
287 | pr_err("Failed Selecting block irq=%d pmirq=%d blk=%d rc=%d\n", | ||
288 | irq, pmirq, block, rc); | ||
289 | goto bail_out; | ||
290 | } | ||
291 | |||
292 | rc = regmap_read(chip->regmap, SSBI_REG_ADDR_IRQ_RT_STATUS, &bits); | ||
293 | if (rc) { | ||
294 | pr_err("Failed Configuring irq=%d pmirq=%d blk=%d rc=%d\n", | ||
295 | irq, pmirq, block, rc); | ||
296 | goto bail_out; | ||
297 | } | ||
298 | |||
299 | rc = (bits & (1 << bit)) ? 1 : 0; | ||
300 | |||
301 | bail_out: | ||
302 | spin_unlock_irqrestore(&chip->pm_irq_lock, flags); | ||
303 | |||
304 | return rc; | ||
305 | } | ||
306 | |||
307 | static int pm8xxx_irq_domain_map(struct irq_domain *d, unsigned int irq, | 251 | static int pm8xxx_irq_domain_map(struct irq_domain *d, unsigned int irq, |
308 | irq_hw_number_t hwirq) | 252 | irq_hw_number_t hwirq) |
309 | { | 253 | { |
@@ -324,56 +268,6 @@ static const struct irq_domain_ops pm8xxx_irq_domain_ops = { | |||
324 | .map = pm8xxx_irq_domain_map, | 268 | .map = pm8xxx_irq_domain_map, |
325 | }; | 269 | }; |
326 | 270 | ||
327 | static int pm8921_readb(const struct device *dev, u16 addr, u8 *val) | ||
328 | { | ||
329 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | ||
330 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | ||
331 | |||
332 | return ssbi_read(pmic->dev->parent, addr, val, 1); | ||
333 | } | ||
334 | |||
335 | static int pm8921_writeb(const struct device *dev, u16 addr, u8 val) | ||
336 | { | ||
337 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | ||
338 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | ||
339 | |||
340 | return ssbi_write(pmic->dev->parent, addr, &val, 1); | ||
341 | } | ||
342 | |||
343 | static int pm8921_read_buf(const struct device *dev, u16 addr, u8 *buf, | ||
344 | int cnt) | ||
345 | { | ||
346 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | ||
347 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | ||
348 | |||
349 | return ssbi_read(pmic->dev->parent, addr, buf, cnt); | ||
350 | } | ||
351 | |||
352 | static int pm8921_write_buf(const struct device *dev, u16 addr, u8 *buf, | ||
353 | int cnt) | ||
354 | { | ||
355 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | ||
356 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | ||
357 | |||
358 | return ssbi_write(pmic->dev->parent, addr, buf, cnt); | ||
359 | } | ||
360 | |||
361 | static int pm8921_read_irq_stat(const struct device *dev, int irq) | ||
362 | { | ||
363 | const struct pm8xxx_drvdata *pm8921_drvdata = dev_get_drvdata(dev); | ||
364 | const struct pm8921 *pmic = pm8921_drvdata->pm_chip_data; | ||
365 | |||
366 | return pm8xxx_get_irq_stat(pmic->irq_chip, irq); | ||
367 | } | ||
368 | |||
369 | static struct pm8xxx_drvdata pm8921_drvdata = { | ||
370 | .pmic_readb = pm8921_readb, | ||
371 | .pmic_writeb = pm8921_writeb, | ||
372 | .pmic_read_buf = pm8921_read_buf, | ||
373 | .pmic_write_buf = pm8921_write_buf, | ||
374 | .pmic_read_irq_stat = pm8921_read_irq_stat, | ||
375 | }; | ||
376 | |||
377 | static const struct regmap_config ssbi_regmap_config = { | 271 | static const struct regmap_config ssbi_regmap_config = { |
378 | .reg_bits = 16, | 272 | .reg_bits = 16, |
379 | .val_bits = 8, | 273 | .val_bits = 8, |
@@ -392,7 +286,6 @@ MODULE_DEVICE_TABLE(of, pm8921_id_table); | |||
392 | 286 | ||
393 | static int pm8921_probe(struct platform_device *pdev) | 287 | static int pm8921_probe(struct platform_device *pdev) |
394 | { | 288 | { |
395 | struct pm8921 *pmic; | ||
396 | struct regmap *regmap; | 289 | struct regmap *regmap; |
397 | int irq, rc; | 290 | int irq, rc; |
398 | unsigned int val; | 291 | unsigned int val; |
@@ -404,12 +297,6 @@ static int pm8921_probe(struct platform_device *pdev) | |||
404 | if (irq < 0) | 297 | if (irq < 0) |
405 | return irq; | 298 | return irq; |
406 | 299 | ||
407 | pmic = devm_kzalloc(&pdev->dev, sizeof(struct pm8921), GFP_KERNEL); | ||
408 | if (!pmic) { | ||
409 | pr_err("Cannot alloc pm8921 struct\n"); | ||
410 | return -ENOMEM; | ||
411 | } | ||
412 | |||
413 | regmap = devm_regmap_init(&pdev->dev, NULL, pdev->dev.parent, | 300 | regmap = devm_regmap_init(&pdev->dev, NULL, pdev->dev.parent, |
414 | &ssbi_regmap_config); | 301 | &ssbi_regmap_config); |
415 | if (IS_ERR(regmap)) | 302 | if (IS_ERR(regmap)) |
@@ -434,18 +321,13 @@ static int pm8921_probe(struct platform_device *pdev) | |||
434 | pr_info("PMIC revision 2: %02X\n", val); | 321 | pr_info("PMIC revision 2: %02X\n", val); |
435 | rev |= val << BITS_PER_BYTE; | 322 | rev |= val << BITS_PER_BYTE; |
436 | 323 | ||
437 | pmic->dev = &pdev->dev; | ||
438 | pm8921_drvdata.pm_chip_data = pmic; | ||
439 | platform_set_drvdata(pdev, &pm8921_drvdata); | ||
440 | |||
441 | chip = devm_kzalloc(&pdev->dev, sizeof(*chip) + | 324 | chip = devm_kzalloc(&pdev->dev, sizeof(*chip) + |
442 | sizeof(chip->config[0]) * nirqs, | 325 | sizeof(chip->config[0]) * nirqs, |
443 | GFP_KERNEL); | 326 | GFP_KERNEL); |
444 | if (!chip) | 327 | if (!chip) |
445 | return -ENOMEM; | 328 | return -ENOMEM; |
446 | 329 | ||
447 | pmic->irq_chip = chip; | 330 | platform_set_drvdata(pdev, chip); |
448 | chip->dev = &pdev->dev; | ||
449 | chip->regmap = regmap; | 331 | chip->regmap = regmap; |
450 | chip->num_irqs = nirqs; | 332 | chip->num_irqs = nirqs; |
451 | chip->num_blocks = DIV_ROUND_UP(chip->num_irqs, 8); | 333 | chip->num_blocks = DIV_ROUND_UP(chip->num_irqs, 8); |
@@ -481,8 +363,7 @@ static int pm8921_remove_child(struct device *dev, void *unused) | |||
481 | static int pm8921_remove(struct platform_device *pdev) | 363 | static int pm8921_remove(struct platform_device *pdev) |
482 | { | 364 | { |
483 | int irq = platform_get_irq(pdev, 0); | 365 | int irq = platform_get_irq(pdev, 0); |
484 | struct pm8921 *pmic = pm8921_drvdata.pm_chip_data; | 366 | struct pm_irq_chip *chip = platform_get_drvdata(pdev); |
485 | struct pm_irq_chip *chip = pmic->irq_chip; | ||
486 | 367 | ||
487 | device_for_each_child(&pdev->dev, NULL, pm8921_remove_child); | 368 | device_for_each_child(&pdev->dev, NULL, pm8921_remove_child); |
488 | irq_set_chained_handler(irq, NULL); | 369 | irq_set_chained_handler(irq, NULL); |
diff --git a/include/linux/mfd/pm8xxx/core.h b/include/linux/mfd/pm8xxx/core.h deleted file mode 100644 index bd2f4f64e931..000000000000 --- a/include/linux/mfd/pm8xxx/core.h +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 and | ||
6 | * only version 2 as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | /* | ||
14 | * Qualcomm PMIC 8xxx driver header file | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #ifndef __MFD_PM8XXX_CORE_H | ||
19 | #define __MFD_PM8XXX_CORE_H | ||
20 | |||
21 | #include <linux/mfd/core.h> | ||
22 | |||
23 | struct pm8xxx_drvdata { | ||
24 | int (*pmic_readb) (const struct device *dev, u16 addr, u8 *val); | ||
25 | int (*pmic_writeb) (const struct device *dev, u16 addr, u8 val); | ||
26 | int (*pmic_read_buf) (const struct device *dev, u16 addr, u8 *buf, | ||
27 | int n); | ||
28 | int (*pmic_write_buf) (const struct device *dev, u16 addr, u8 *buf, | ||
29 | int n); | ||
30 | int (*pmic_read_irq_stat) (const struct device *dev, int irq); | ||
31 | void *pm_chip_data; | ||
32 | }; | ||
33 | |||
34 | static inline int pm8xxx_readb(const struct device *dev, u16 addr, u8 *val) | ||
35 | { | ||
36 | struct pm8xxx_drvdata *dd = dev_get_drvdata(dev); | ||
37 | |||
38 | if (!dd) | ||
39 | return -EINVAL; | ||
40 | return dd->pmic_readb(dev, addr, val); | ||
41 | } | ||
42 | |||
43 | static inline int pm8xxx_writeb(const struct device *dev, u16 addr, u8 val) | ||
44 | { | ||
45 | struct pm8xxx_drvdata *dd = dev_get_drvdata(dev); | ||
46 | |||
47 | if (!dd) | ||
48 | return -EINVAL; | ||
49 | return dd->pmic_writeb(dev, addr, val); | ||
50 | } | ||
51 | |||
52 | static inline int pm8xxx_read_buf(const struct device *dev, u16 addr, u8 *buf, | ||
53 | int n) | ||
54 | { | ||
55 | struct pm8xxx_drvdata *dd = dev_get_drvdata(dev); | ||
56 | |||
57 | if (!dd) | ||
58 | return -EINVAL; | ||
59 | return dd->pmic_read_buf(dev, addr, buf, n); | ||
60 | } | ||
61 | |||
62 | static inline int pm8xxx_write_buf(const struct device *dev, u16 addr, u8 *buf, | ||
63 | int n) | ||
64 | { | ||
65 | struct pm8xxx_drvdata *dd = dev_get_drvdata(dev); | ||
66 | |||
67 | if (!dd) | ||
68 | return -EINVAL; | ||
69 | return dd->pmic_write_buf(dev, addr, buf, n); | ||
70 | } | ||
71 | |||
72 | static inline int pm8xxx_read_irq_stat(const struct device *dev, int irq) | ||
73 | { | ||
74 | struct pm8xxx_drvdata *dd = dev_get_drvdata(dev); | ||
75 | |||
76 | if (!dd) | ||
77 | return -EINVAL; | ||
78 | return dd->pmic_read_irq_stat(dev, irq); | ||
79 | } | ||
80 | |||
81 | #endif | ||