x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / drivers / mfd / abx500-core.c
blob0d3846a4767cba7479f68d7ab4badded7bb3019b
1 /*
2 * Copyright (C) 2007-2010 ST-Ericsson
3 * License terms: GNU General Public License (GPL) version 2
4 * Register access functions for the ABX500 Mixed Signal IC family.
5 * Author: Mattias Wallin <mattias.wallin@stericsson.com>
6 */
8 #include <linux/list.h>
9 #include <linux/slab.h>
10 #include <linux/err.h>
11 #include <linux/init.h>
12 #include <linux/export.h>
13 #include <linux/mfd/abx500.h>
15 static LIST_HEAD(abx500_list);
17 struct abx500_device_entry {
18 struct list_head list;
19 struct abx500_ops ops;
20 struct device *dev;
23 static void lookup_ops(struct device *dev, struct abx500_ops **ops)
25 struct abx500_device_entry *dev_entry;
27 *ops = NULL;
28 list_for_each_entry(dev_entry, &abx500_list, list) {
29 if (dev_entry->dev == dev) {
30 *ops = &dev_entry->ops;
31 return;
36 int abx500_register_ops(struct device *dev, struct abx500_ops *ops)
38 struct abx500_device_entry *dev_entry;
40 dev_entry = devm_kzalloc(dev,
41 sizeof(struct abx500_device_entry),
42 GFP_KERNEL);
43 if (!dev_entry) {
44 dev_err(dev, "register_ops kzalloc failed");
45 return -ENOMEM;
47 dev_entry->dev = dev;
48 memcpy(&dev_entry->ops, ops, sizeof(struct abx500_ops));
50 list_add_tail(&dev_entry->list, &abx500_list);
51 return 0;
53 EXPORT_SYMBOL(abx500_register_ops);
55 void abx500_remove_ops(struct device *dev)
57 struct abx500_device_entry *dev_entry, *tmp;
59 list_for_each_entry_safe(dev_entry, tmp, &abx500_list, list)
60 if (dev_entry->dev == dev)
61 list_del(&dev_entry->list);
63 EXPORT_SYMBOL(abx500_remove_ops);
65 int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,
66 u8 value)
68 struct abx500_ops *ops;
70 lookup_ops(dev->parent, &ops);
71 if ((ops != NULL) && (ops->set_register != NULL))
72 return ops->set_register(dev, bank, reg, value);
73 else
74 return -ENOTSUPP;
76 EXPORT_SYMBOL(abx500_set_register_interruptible);
78 int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,
79 u8 *value)
81 struct abx500_ops *ops;
83 lookup_ops(dev->parent, &ops);
84 if ((ops != NULL) && (ops->get_register != NULL))
85 return ops->get_register(dev, bank, reg, value);
86 else
87 return -ENOTSUPP;
89 EXPORT_SYMBOL(abx500_get_register_interruptible);
91 int abx500_get_register_page_interruptible(struct device *dev, u8 bank,
92 u8 first_reg, u8 *regvals, u8 numregs)
94 struct abx500_ops *ops;
96 lookup_ops(dev->parent, &ops);
97 if ((ops != NULL) && (ops->get_register_page != NULL))
98 return ops->get_register_page(dev, bank,
99 first_reg, regvals, numregs);
100 else
101 return -ENOTSUPP;
103 EXPORT_SYMBOL(abx500_get_register_page_interruptible);
105 int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank,
106 u8 reg, u8 bitmask, u8 bitvalues)
108 struct abx500_ops *ops;
110 lookup_ops(dev->parent, &ops);
111 if ((ops != NULL) && (ops->mask_and_set_register != NULL))
112 return ops->mask_and_set_register(dev, bank,
113 reg, bitmask, bitvalues);
114 else
115 return -ENOTSUPP;
117 EXPORT_SYMBOL(abx500_mask_and_set_register_interruptible);
119 int abx500_get_chip_id(struct device *dev)
121 struct abx500_ops *ops;
123 lookup_ops(dev->parent, &ops);
124 if ((ops != NULL) && (ops->get_chip_id != NULL))
125 return ops->get_chip_id(dev);
126 else
127 return -ENOTSUPP;
129 EXPORT_SYMBOL(abx500_get_chip_id);
131 int abx500_event_registers_startup_state_get(struct device *dev, u8 *event)
133 struct abx500_ops *ops;
135 lookup_ops(dev->parent, &ops);
136 if ((ops != NULL) && (ops->event_registers_startup_state_get != NULL))
137 return ops->event_registers_startup_state_get(dev, event);
138 else
139 return -ENOTSUPP;
141 EXPORT_SYMBOL(abx500_event_registers_startup_state_get);
143 int abx500_startup_irq_enabled(struct device *dev, unsigned int irq)
145 struct abx500_ops *ops;
147 lookup_ops(dev->parent, &ops);
148 if ((ops != NULL) && (ops->startup_irq_enabled != NULL))
149 return ops->startup_irq_enabled(dev, irq);
150 else
151 return -ENOTSUPP;
153 EXPORT_SYMBOL(abx500_startup_irq_enabled);