2 * SPI access for Dialog DA9052 PMICs.
4 * Copyright(c) 2011 Dialog Semiconductor Ltd.
6 * Author: David Dajun Chen <dchen@diasemi.com>
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.
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>
22 #include <linux/mfd/da9052/da9052.h>
24 static int __devinit
da9052_spi_probe(struct spi_device
*spi
)
27 const struct spi_device_id
*id
= spi_get_device_id(spi
);
28 struct da9052
*da9052
= kzalloc(sizeof(struct da9052
), GFP_KERNEL
);
33 spi
->mode
= SPI_MODE_0
| SPI_CPOL
;
34 spi
->bits_per_word
= 8;
37 da9052
->dev
= &spi
->dev
;
38 da9052
->chip_irq
= spi
->irq
;
40 dev_set_drvdata(&spi
->dev
, da9052
);
42 da9052_regmap_config
.read_flag_mask
= 1;
43 da9052_regmap_config
.write_flag_mask
= 0;
45 da9052
->regmap
= regmap_init_spi(spi
, &da9052_regmap_config
);
46 if (IS_ERR(da9052
->regmap
)) {
47 ret
= PTR_ERR(da9052
->regmap
);
48 dev_err(&spi
->dev
, "Failed to allocate register map: %d\n",
53 ret
= da9052_device_init(da9052
, id
->driver_data
);
64 static int __devexit
da9052_spi_remove(struct spi_device
*spi
)
66 struct da9052
*da9052
= dev_get_drvdata(&spi
->dev
);
68 da9052_device_exit(da9052
);
74 static struct spi_device_id da9052_spi_id
[] = {
76 {"da9053-aa", DA9053_AA
},
77 {"da9053-ba", DA9053_BA
},
78 {"da9053-bb", DA9053_BB
},
82 static struct spi_driver da9052_spi_driver
= {
83 .probe
= da9052_spi_probe
,
84 .remove
= __devexit_p(da9052_spi_remove
),
85 .id_table
= da9052_spi_id
,
93 static int __init
da9052_spi_init(void)
97 ret
= spi_register_driver(&da9052_spi_driver
);
99 pr_err("Failed to register DA9052 SPI driver, %d\n", ret
);
105 subsys_initcall(da9052_spi_init
);
107 static void __exit
da9052_spi_exit(void)
109 spi_unregister_driver(&da9052_spi_driver
);
111 module_exit(da9052_spi_exit
);
113 MODULE_AUTHOR("David Dajun Chen <dchen@diasemi.com>");
114 MODULE_DESCRIPTION("SPI driver for Dialog DA9052 PMIC");
115 MODULE_LICENSE("GPL");