drm/connector: store tile information from displayid (v3)
[deliverable/linux.git] / drivers / mfd / da9052-spi.c
CommitLineData
cfe04478
AJ
1/*
2 * SPI access for Dialog DA9052 PMICs.
3 *
4 * Copyright(c) 2011 Dialog Semiconductor Ltd.
5 *
6 * Author: David Dajun Chen <dchen@diasemi.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14
15#include <linux/device.h>
16#include <linux/module.h>
17#include <linux/input.h>
18#include <linux/mfd/core.h>
19#include <linux/spi/spi.h>
20#include <linux/err.h>
21
22#include <linux/mfd/da9052/da9052.h>
23
f791be49 24static int da9052_spi_probe(struct spi_device *spi)
cfe04478 25{
e9e9d397 26 struct regmap_config config;
cfe04478
AJ
27 int ret;
28 const struct spi_device_id *id = spi_get_device_id(spi);
6608a5e2 29 struct da9052 *da9052;
cfe04478 30
6608a5e2 31 da9052 = devm_kzalloc(&spi->dev, sizeof(struct da9052), GFP_KERNEL);
cfe04478
AJ
32 if (!da9052)
33 return -ENOMEM;
34
35 spi->mode = SPI_MODE_0 | SPI_CPOL;
36 spi->bits_per_word = 8;
37 spi_setup(spi);
38
39 da9052->dev = &spi->dev;
40 da9052->chip_irq = spi->irq;
41
1b1ba09c 42 spi_set_drvdata(spi, da9052);
cfe04478 43
e9e9d397
AL
44 config = da9052_regmap_config;
45 config.read_flag_mask = 1;
cfe04478 46
e9e9d397 47 da9052->regmap = devm_regmap_init_spi(spi, &config);
cfe04478
AJ
48 if (IS_ERR(da9052->regmap)) {
49 ret = PTR_ERR(da9052->regmap);
50 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
51 ret);
6608a5e2 52 return ret;
cfe04478
AJ
53 }
54
55 ret = da9052_device_init(da9052, id->driver_data);
56 if (ret != 0)
6608a5e2 57 return ret;
cfe04478
AJ
58
59 return 0;
cfe04478
AJ
60}
61
4740f73f 62static int da9052_spi_remove(struct spi_device *spi)
cfe04478 63{
1b1ba09c 64 struct da9052 *da9052 = spi_get_drvdata(spi);
cfe04478
AJ
65
66 da9052_device_exit(da9052);
cfe04478
AJ
67 return 0;
68}
69
70static struct spi_device_id da9052_spi_id[] = {
71 {"da9052", DA9052},
72 {"da9053-aa", DA9053_AA},
73 {"da9053-ba", DA9053_BA},
74 {"da9053-bb", DA9053_BB},
6c049b2a 75 {"da9053-bc", DA9053_BC},
cfe04478
AJ
76 {}
77};
78
79static struct spi_driver da9052_spi_driver = {
80 .probe = da9052_spi_probe,
84449216 81 .remove = da9052_spi_remove,
cfe04478
AJ
82 .id_table = da9052_spi_id,
83 .driver = {
84 .name = "da9052",
cfe04478
AJ
85 .owner = THIS_MODULE,
86 },
87};
88
89static int __init da9052_spi_init(void)
90{
91 int ret;
92
93 ret = spi_register_driver(&da9052_spi_driver);
94 if (ret != 0) {
95 pr_err("Failed to register DA9052 SPI driver, %d\n", ret);
96 return ret;
97 }
98
99 return 0;
100}
101subsys_initcall(da9052_spi_init);
102
103static void __exit da9052_spi_exit(void)
104{
105 spi_unregister_driver(&da9052_spi_driver);
106}
107module_exit(da9052_spi_exit);
108
109MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
110MODULE_DESCRIPTION("SPI driver for Dialog DA9052 PMIC");
111MODULE_LICENSE("GPL");
This page took 0.228419 seconds and 5 git commands to generate.