Update the adm5120 config to use IRQ_CPU and physically mapped flash for now
[openwrt.git] / target / linux / ixp4xx-2.6 / patches / 800-eeprom_new_notifier.patch
1 Add EEPROM notifiers
2
3 These help board level code by allowing a callback when EEPROMs are
4 loaded, this permits system level configuration to be loaded from the
5 EEPROM. This is particularly useful when the ethernet MAC ids are
6 stored in EEPROM and when the ethernet hardware is generic (so it
7 has no board level knowledge), then the MACs can be loaded into
8 the 'maclist' code and read out by the ethernet config.
9
10 Signed-off-by: John Bowler <jbowler@acm.org>
11
12 Index: linux-2.6.21-rc1-arm/drivers/i2c/chips/eeprom.c
13 ===================================================================
14 --- linux-2.6.21-rc1-arm.orig/drivers/i2c/chips/eeprom.c 2007-02-21 02:24:14.000000000 -0800
15 +++ linux-2.6.21-rc1-arm/drivers/i2c/chips/eeprom.c 2007-02-21 02:25:01.000000000 -0800
16 @@ -33,6 +33,8 @@
17 #include <linux/jiffies.h>
18 #include <linux/i2c.h>
19 #include <linux/mutex.h>
20 +#include <linux/notifier.h>
21 +#include <linux/eeprom.h>
22
23 /* Addresses to scan */
24 static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
25 @@ -41,26 +43,7 @@
26 /* Insmod parameters */
27 I2C_CLIENT_INSMOD_1(eeprom);
28
29 -
30 -/* Size of EEPROM in bytes */
31 -#define EEPROM_SIZE 256
32 -
33 -/* possible types of eeprom devices */
34 -enum eeprom_nature {
35 - UNKNOWN,
36 - VAIO,
37 -};
38 -
39 -/* Each client has this additional data */
40 -struct eeprom_data {
41 - struct i2c_client client;
42 - struct mutex update_lock;
43 - u8 valid; /* bitfield, bit!=0 if slice is valid */
44 - unsigned long last_updated[8]; /* In jiffies, 8 slices */
45 - u8 data[EEPROM_SIZE]; /* Register values */
46 - enum eeprom_nature nature;
47 -};
48 -
49 +ATOMIC_NOTIFIER_HEAD(eeprom_chain);
50
51 static int eeprom_attach_adapter(struct i2c_adapter *adapter);
52 static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind);
53 @@ -189,6 +172,7 @@
54 data->valid = 0;
55 mutex_init(&data->update_lock);
56 data->nature = UNKNOWN;
57 + data->attr = &eeprom_attr;
58
59 /* Tell the I2C layer a new client has arrived */
60 if ((err = i2c_attach_client(new_client)))
61 @@ -212,6 +196,9 @@
62 if (err)
63 goto exit_detach;
64
65 + /* call the notifier chain */
66 + atomic_notifier_call_chain(&eeprom_chain, EEPROM_REGISTER, data);
67 +
68 return 0;
69
70 exit_detach:
71 @@ -237,6 +224,41 @@
72 return 0;
73 }
74
75 +/**
76 + * register_eeprom_notifier - register a 'user' of EEPROM devices.
77 + * @nb: pointer to notifier info structure
78 + *
79 + * Registers a callback function to be called upon detection
80 + * of an EEPROM device. Detection invokes the 'add' callback
81 + * with the kobj of the mutex and a bin_attribute which allows
82 + * read from the EEPROM. The intention is that the notifier
83 + * will be able to read system configuration from the notifier.
84 + *
85 + * Only EEPROMs detected *after* the addition of the notifier
86 + * are notified. I.e. EEPROMs already known to the system
87 + * will not be notified - add the notifier from board level
88 + * code!
89 + */
90 +int register_eeprom_notifier(struct notifier_block *nb)
91 +{
92 + return atomic_notifier_chain_register(&eeprom_chain, nb);
93 +}
94 +
95 +/**
96 + * unregister_eeprom_notifier - unregister a 'user' of EEPROM devices.
97 + * @old: pointer to notifier info structure
98 + *
99 + * Removes a callback function from the list of 'users' to be
100 + * notified upon detection of EEPROM devices.
101 + */
102 +int unregister_eeprom_notifier(struct notifier_block *nb)
103 +{
104 + return atomic_notifier_chain_unregister(&eeprom_chain, nb);
105 +}
106 +
107 +EXPORT_SYMBOL_GPL(register_eeprom_notifier);
108 +EXPORT_SYMBOL_GPL(unregister_eeprom_notifier);
109 +
110 static int __init eeprom_init(void)
111 {
112 return i2c_add_driver(&eeprom_driver);
113 Index: linux-2.6.21-rc1-arm/include/linux/eeprom.h
114 ===================================================================
115 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
116 +++ linux-2.6.21-rc1-arm/include/linux/eeprom.h 2007-02-21 02:25:01.000000000 -0800
117 @@ -0,0 +1,71 @@
118 +#ifndef _LINUX_EEPROM_H
119 +#define _LINUX_EEPROM_H
120 +/*
121 + * $Id: 45-eeprom-new-notifier.patch,v 1.2 2006/03/27 11:10:19 azummo Exp $
122 + *
123 + * Copyright (C) 2006 John Bowler
124 + */
125 +
126 +/*
127 + * This program is free software; you can redistribute it and/or modify
128 + * it under the terms of the GNU General Public License as published by
129 + * the Free Software Foundation; either version 2 of the License, or
130 + * (at your option) any later version.
131 + *
132 + * This program is distributed in the hope that it will be useful,
133 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
134 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135 + * GNU General Public License for more details.
136 + *
137 + * You should have received a copy of the GNU General Public License
138 + * along with this program; if not, write to the Free Software
139 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
140 + */
141 +
142 +#ifndef __KERNEL__
143 +#error This is a kernel header
144 +#endif
145 +
146 +#include <linux/list.h>
147 +#include <linux/kobject.h>
148 +#include <linux/sysfs.h>
149 +
150 +/* Size of EEPROM in bytes */
151 +#define EEPROM_SIZE 256
152 +
153 +/* possible types of eeprom devices */
154 +enum eeprom_nature {
155 + UNKNOWN,
156 + VAIO,
157 +};
158 +
159 +/* Each client has this additional data */
160 +struct eeprom_data {
161 + struct i2c_client client;
162 + struct mutex update_lock;
163 + u8 valid; /* bitfield, bit!=0 if slice is valid */
164 + unsigned long last_updated[8]; /* In jiffies, 8 slices */
165 + u8 data[EEPROM_SIZE]; /* Register values */
166 + enum eeprom_nature nature;
167 + struct bin_attribute *attr;
168 +};
169 +
170 +/*
171 + * This is very basic.
172 + *
173 + * If an EEPROM is detected on the I2C bus (this only works for
174 + * I2C EEPROMs) the notifier chain is called with
175 + * both the I2C information and the kobject for the sysfs
176 + * device which has been registers. It is then possible to
177 + * read from the device via the bin_attribute::read method
178 + * to extract configuration information.
179 + *
180 + * Register the notifier in the board level code, there is no
181 + * need to unregister it but you can if you want (it will save
182 + * a little bit or kernel memory to do so).
183 + */
184 +
185 +extern int register_eeprom_notifier(struct notifier_block *nb);
186 +extern int unregister_eeprom_notifier(struct notifier_block *nb);
187 +
188 +#endif /* _LINUX_EEPROM_H */
189 Index: linux-2.6.21-rc1-arm/include/linux/notifier.h
190 ===================================================================
191 --- linux-2.6.21-rc1-arm.orig/include/linux/notifier.h 2007-02-21 02:24:14.000000000 -0800
192 +++ linux-2.6.21-rc1-arm/include/linux/notifier.h 2007-02-21 02:25:01.000000000 -0800
193 @@ -187,5 +187,8 @@
194 #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
195 #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
196
197 +/* eeprom notifier chain */
198 +#define EEPROM_REGISTER 0x0001
199 +
200 #endif /* __KERNEL__ */
201 #endif /* _LINUX_NOTIFIER_H */
This page took 0.04777 seconds and 5 git commands to generate.