Blame view
drivers/mfd/arizona-spi.c
2.69 KB
a15123c70
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
/* * arizona-spi.c -- Arizona SPI bus interface * * Copyright 2012 Wolfson Microelectronics plc * * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/err.h> #include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/spi/spi.h> |
3d6d1d1cd
|
20 |
#include <linux/of.h> |
a15123c70
|
21 22 23 24 |
#include <linux/mfd/arizona/core.h> #include "arizona.h" |
f791be492
|
25 |
static int arizona_spi_probe(struct spi_device *spi) |
a15123c70
|
26 27 28 |
{ const struct spi_device_id *id = spi_get_device_id(spi); struct arizona *arizona; |
b61c1ec05
|
29 |
const struct regmap_config *regmap_config = NULL; |
942786e6e
|
30 31 |
unsigned long type; int ret; |
a15123c70
|
32 |
|
d781009ca
|
33 34 35 36 37 38 |
if (spi->dev.of_node) type = arizona_of_get_type(&spi->dev); else type = id->driver_data; switch (type) { |
a15123c70
|
39 |
case WM5102: |
b61c1ec05
|
40 41 |
if (IS_ENABLED(CONFIG_MFD_WM5102)) regmap_config = &wm5102_spi_regmap; |
a15123c70
|
42 |
break; |
e102befe7
|
43 |
case WM5110: |
e5d4ef0d7
|
44 |
case WM8280: |
b61c1ec05
|
45 46 |
if (IS_ENABLED(CONFIG_MFD_WM5110)) regmap_config = &wm5110_spi_regmap; |
e102befe7
|
47 |
break; |
ea1f33399
|
48 49 50 51 52 |
case WM1831: case CS47L24: if (IS_ENABLED(CONFIG_MFD_CS47L24)) regmap_config = &cs47l24_spi_regmap; break; |
a15123c70
|
53 |
default: |
2e44e28ad
|
54 55 |
dev_err(&spi->dev, "Unknown device type %ld ", type); |
a15123c70
|
56 57 |
return -EINVAL; } |
b61c1ec05
|
58 59 60 61 |
if (!regmap_config) { dev_err(&spi->dev, "No kernel support for device type %ld ", type); |
a15123c70
|
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
return -EINVAL; } arizona = devm_kzalloc(&spi->dev, sizeof(*arizona), GFP_KERNEL); if (arizona == NULL) return -ENOMEM; arizona->regmap = devm_regmap_init_spi(spi, regmap_config); if (IS_ERR(arizona->regmap)) { ret = PTR_ERR(arizona->regmap); dev_err(&spi->dev, "Failed to allocate register map: %d ", ret); return ret; } |
2e44e28ad
|
77 |
arizona->type = type; |
a15123c70
|
78 79 80 81 82 |
arizona->dev = &spi->dev; arizona->irq = spi->irq; return arizona_dev_init(arizona); } |
4740f73fe
|
83 |
static int arizona_spi_remove(struct spi_device *spi) |
a15123c70
|
84 |
{ |
e9642d5e1
|
85 |
struct arizona *arizona = spi_get_drvdata(spi); |
6f467e5f0
|
86 |
|
a15123c70
|
87 |
arizona_dev_exit(arizona); |
6f467e5f0
|
88 |
|
a15123c70
|
89 90 91 92 93 |
return 0; } static const struct spi_device_id arizona_spi_ids[] = { { "wm5102", WM5102 }, |
e102befe7
|
94 |
{ "wm5110", WM5110 }, |
e5d4ef0d7
|
95 |
{ "wm8280", WM8280 }, |
ea1f33399
|
96 97 |
{ "wm1831", WM1831 }, { "cs47l24", CS47L24 }, |
a15123c70
|
98 99 100 101 102 103 104 |
{ }, }; MODULE_DEVICE_TABLE(spi, arizona_spi_ids); static struct spi_driver arizona_spi_driver = { .driver = { .name = "arizona", |
a15123c70
|
105 |
.pm = &arizona_pm_ops, |
d781009ca
|
106 |
.of_match_table = of_match_ptr(arizona_of_match), |
a15123c70
|
107 108 |
}, .probe = arizona_spi_probe, |
84449216b
|
109 |
.remove = arizona_spi_remove, |
a15123c70
|
110 111 112 113 114 115 116 117 |
.id_table = arizona_spi_ids, }; module_spi_driver(arizona_spi_driver); MODULE_DESCRIPTION("Arizona SPI bus interface"); MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); MODULE_LICENSE("GPL"); |