sh_eth: fix EESIPR values for SH77{34|63}
[linux/fpc-iii.git] / drivers / mfd / smsc-ece1099.c
blob1f40baf1234e3e053918e81805117027f7b40100
1 /*
2 * TI SMSC MFD Driver
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
6 * Author: Sourav Poddar <sourav.poddar@ti.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; GPL v2.
14 #include <linux/init.h>
15 #include <linux/slab.h>
16 #include <linux/i2c.h>
17 #include <linux/gpio.h>
18 #include <linux/workqueue.h>
19 #include <linux/irq.h>
20 #include <linux/regmap.h>
21 #include <linux/err.h>
22 #include <linux/mfd/core.h>
23 #include <linux/mfd/smsc.h>
24 #include <linux/of_platform.h>
26 static const struct regmap_config smsc_regmap_config = {
27 .reg_bits = 8,
28 .val_bits = 8,
29 .max_register = SMSC_VEN_ID_H,
30 .cache_type = REGCACHE_RBTREE,
33 static int smsc_i2c_probe(struct i2c_client *i2c,
34 const struct i2c_device_id *id)
36 struct smsc *smsc;
37 int devid, rev, venid_l, venid_h;
38 int ret;
40 smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc),
41 GFP_KERNEL);
42 if (!smsc) {
43 dev_err(&i2c->dev, "smsc mfd driver memory allocation failed\n");
44 return -ENOMEM;
47 smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config);
48 if (IS_ERR(smsc->regmap))
49 return PTR_ERR(smsc->regmap);
51 i2c_set_clientdata(i2c, smsc);
52 smsc->dev = &i2c->dev;
54 #ifdef CONFIG_OF
55 of_property_read_u32(i2c->dev.of_node, "clock", &smsc->clk);
56 #endif
58 regmap_read(smsc->regmap, SMSC_DEV_ID, &devid);
59 regmap_read(smsc->regmap, SMSC_DEV_REV, &rev);
60 regmap_read(smsc->regmap, SMSC_VEN_ID_L, &venid_l);
61 regmap_read(smsc->regmap, SMSC_VEN_ID_H, &venid_h);
63 dev_info(&i2c->dev, "SMSCxxx devid: %02x rev: %02x venid: %02x\n",
64 devid, rev, (venid_h << 8) | venid_l);
66 ret = regmap_write(smsc->regmap, SMSC_CLK_CTRL, smsc->clk);
67 if (ret)
68 return ret;
70 #ifdef CONFIG_OF
71 if (i2c->dev.of_node)
72 ret = of_platform_populate(i2c->dev.of_node,
73 NULL, NULL, &i2c->dev);
74 #endif
76 return ret;
79 static const struct i2c_device_id smsc_i2c_id[] = {
80 { "smscece1099", 0},
81 {},
84 static struct i2c_driver smsc_i2c_driver = {
85 .driver = {
86 .name = "smsc",
88 .probe = smsc_i2c_probe,
89 .id_table = smsc_i2c_id,
91 builtin_i2c_driver(smsc_i2c_driver);