15 #include <linux/kernel.h>
16 #include <linux/device.h>
18 #include <linux/module.h>
19 #include <linux/types.h>
23 #include <linux/i2c.h>
25 #include <linux/slab.h>
92 static u8 address_no_read[] = {
101 for (n = 0; n < 256; n +=
sizeof(
dump)) {
102 for (n1 = 0; n1 <
sizeof(
dump); n1++)
103 if (n == address_no_read[idx]) {
125 n =
sprintf(buf,
"%02x%02x%02x%02x%02x\n",
136 static struct attribute *pcf_sysfs_entries[] = {
137 &dev_attr_dump_regs.attr,
138 &dev_attr_resume_reason.attr,
144 .attrs = pcf_sysfs_entries,
148 pcf50633_client_dev_register(
struct pcf50633 *pcf,
const char *
name,
155 dev_err(pcf->
dev,
"Falied to allocate %s\n", name);
159 (*pdev)->dev.parent = pcf->
dev;
163 dev_err(pcf->
dev,
"Failed to register %s: %d\n", name, ret);
169 #ifdef CONFIG_PM_SLEEP
170 static int pcf50633_suspend(
struct device *dev)
173 struct pcf50633 *pcf = i2c_get_clientdata(client);
175 return pcf50633_irq_suspend(pcf);
178 static int pcf50633_resume(
struct device *dev)
181 struct pcf50633 *pcf = i2c_get_clientdata(client);
183 return pcf50633_irq_resume(pcf);
189 static struct regmap_config pcf50633_regmap_config = {
216 if (IS_ERR(pcf->
regmap)) {
217 ret = PTR_ERR(pcf->
regmap);
218 dev_err(pcf->
dev,
"Failed to allocate register map: %d\n", ret);
222 i2c_set_clientdata(client, pcf);
227 if (version < 0 || variant < 0) {
228 dev_err(pcf->
dev,
"Unable to probe pcf50633\n");
233 dev_info(pcf->
dev,
"Probed device version %d variant %d\n",
239 pcf50633_client_dev_register(pcf,
"pcf50633-input", &pcf->
input_pdev);
240 pcf50633_client_dev_register(pcf,
"pcf50633-rtc", &pcf->
rtc_pdev);
241 pcf50633_client_dev_register(pcf,
"pcf50633-mbc", &pcf->
mbc_pdev);
242 pcf50633_client_dev_register(pcf,
"pcf50633-adc", &pcf->
adc_pdev);
243 pcf50633_client_dev_register(pcf,
"pcf50633-backlight", &pcf->
bl_pdev);
251 dev_err(pcf->
dev,
"Cannot create regulator %d\n", i);
255 pdev->
dev.parent = pcf->
dev;
259 dev_err(pcf->
dev,
"Out of memory for regulator parameters %d\n",
270 dev_err(pcf->
dev,
"error creating sysfs entries\n");
280 struct pcf50633 *pcf = i2c_get_clientdata(client);
309 .id_table = pcf50633_id_table,
310 .probe = pcf50633_probe,
314 static int __init pcf50633_init(
void)
316 return i2c_add_driver(&pcf50633_driver);
319 static void __exit pcf50633_exit(
void)