diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/amba/bus.c | 88 | ||||
-rw-r--r-- | drivers/misc/Kconfig | 10 | ||||
-rw-r--r-- | drivers/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/arm-charlcd.c | 396 | ||||
-rw-r--r-- | drivers/usb/gadget/at91_udc.c | 205 | ||||
-rw-r--r-- | drivers/usb/gadget/at91_udc.h | 3 | ||||
-rw-r--r-- | drivers/video/omap2/vram.c | 33 |
7 files changed, 640 insertions, 96 deletions
diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index f60b2b6a0931..d31590e7011b 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c | |||
@@ -122,6 +122,31 @@ static int __init amba_init(void) | |||
122 | 122 | ||
123 | postcore_initcall(amba_init); | 123 | postcore_initcall(amba_init); |
124 | 124 | ||
125 | static int amba_get_enable_pclk(struct amba_device *pcdev) | ||
126 | { | ||
127 | struct clk *pclk = clk_get(&pcdev->dev, "apb_pclk"); | ||
128 | int ret; | ||
129 | |||
130 | pcdev->pclk = pclk; | ||
131 | |||
132 | if (IS_ERR(pclk)) | ||
133 | return PTR_ERR(pclk); | ||
134 | |||
135 | ret = clk_enable(pclk); | ||
136 | if (ret) | ||
137 | clk_put(pclk); | ||
138 | |||
139 | return ret; | ||
140 | } | ||
141 | |||
142 | static void amba_put_disable_pclk(struct amba_device *pcdev) | ||
143 | { | ||
144 | struct clk *pclk = pcdev->pclk; | ||
145 | |||
146 | clk_disable(pclk); | ||
147 | clk_put(pclk); | ||
148 | } | ||
149 | |||
125 | /* | 150 | /* |
126 | * These are the device model conversion veneers; they convert the | 151 | * These are the device model conversion veneers; they convert the |
127 | * device model structures to our more specific structures. | 152 | * device model structures to our more specific structures. |
@@ -130,17 +155,33 @@ static int amba_probe(struct device *dev) | |||
130 | { | 155 | { |
131 | struct amba_device *pcdev = to_amba_device(dev); | 156 | struct amba_device *pcdev = to_amba_device(dev); |
132 | struct amba_driver *pcdrv = to_amba_driver(dev->driver); | 157 | struct amba_driver *pcdrv = to_amba_driver(dev->driver); |
133 | struct amba_id *id; | 158 | struct amba_id *id = amba_lookup(pcdrv->id_table, pcdev); |
159 | int ret; | ||
134 | 160 | ||
135 | id = amba_lookup(pcdrv->id_table, pcdev); | 161 | do { |
162 | ret = amba_get_enable_pclk(pcdev); | ||
163 | if (ret) | ||
164 | break; | ||
165 | |||
166 | ret = pcdrv->probe(pcdev, id); | ||
167 | if (ret == 0) | ||
168 | break; | ||
136 | 169 | ||
137 | return pcdrv->probe(pcdev, id); | 170 | amba_put_disable_pclk(pcdev); |
171 | } while (0); | ||
172 | |||
173 | return ret; | ||
138 | } | 174 | } |
139 | 175 | ||
140 | static int amba_remove(struct device *dev) | 176 | static int amba_remove(struct device *dev) |
141 | { | 177 | { |
178 | struct amba_device *pcdev = to_amba_device(dev); | ||
142 | struct amba_driver *drv = to_amba_driver(dev->driver); | 179 | struct amba_driver *drv = to_amba_driver(dev->driver); |
143 | return drv->remove(to_amba_device(dev)); | 180 | int ret = drv->remove(pcdev); |
181 | |||
182 | amba_put_disable_pclk(pcdev); | ||
183 | |||
184 | return ret; | ||
144 | } | 185 | } |
145 | 186 | ||
146 | static void amba_shutdown(struct device *dev) | 187 | static void amba_shutdown(struct device *dev) |
@@ -203,7 +244,6 @@ static void amba_device_release(struct device *dev) | |||
203 | */ | 244 | */ |
204 | int amba_device_register(struct amba_device *dev, struct resource *parent) | 245 | int amba_device_register(struct amba_device *dev, struct resource *parent) |
205 | { | 246 | { |
206 | u32 pid, cid; | ||
207 | u32 size; | 247 | u32 size; |
208 | void __iomem *tmp; | 248 | void __iomem *tmp; |
209 | int i, ret; | 249 | int i, ret; |
@@ -241,25 +281,35 @@ int amba_device_register(struct amba_device *dev, struct resource *parent) | |||
241 | goto err_release; | 281 | goto err_release; |
242 | } | 282 | } |
243 | 283 | ||
244 | /* | 284 | ret = amba_get_enable_pclk(dev); |
245 | * Read pid and cid based on size of resource | 285 | if (ret == 0) { |
246 | * they are located at end of region | 286 | u32 pid, cid; |
247 | */ | ||
248 | for (pid = 0, i = 0; i < 4; i++) | ||
249 | pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << (i * 8); | ||
250 | for (cid = 0, i = 0; i < 4; i++) | ||
251 | cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << (i * 8); | ||
252 | 287 | ||
253 | iounmap(tmp); | 288 | /* |
289 | * Read pid and cid based on size of resource | ||
290 | * they are located at end of region | ||
291 | */ | ||
292 | for (pid = 0, i = 0; i < 4; i++) | ||
293 | pid |= (readl(tmp + size - 0x20 + 4 * i) & 255) << | ||
294 | (i * 8); | ||
295 | for (cid = 0, i = 0; i < 4; i++) | ||
296 | cid |= (readl(tmp + size - 0x10 + 4 * i) & 255) << | ||
297 | (i * 8); | ||
254 | 298 | ||
255 | if (cid == 0xb105f00d) | 299 | amba_put_disable_pclk(dev); |
256 | dev->periphid = pid; | ||
257 | 300 | ||
258 | if (!dev->periphid) { | 301 | if (cid == 0xb105f00d) |
259 | ret = -ENODEV; | 302 | dev->periphid = pid; |
260 | goto err_release; | 303 | |
304 | if (!dev->periphid) | ||
305 | ret = -ENODEV; | ||
261 | } | 306 | } |
262 | 307 | ||
308 | iounmap(tmp); | ||
309 | |||
310 | if (ret) | ||
311 | goto err_release; | ||
312 | |||
263 | ret = device_add(&dev->dev); | 313 | ret = device_add(&dev->dev); |
264 | if (ret) | 314 | if (ret) |
265 | goto err_release; | 315 | goto err_release; |
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 26386a92f5aa..9b089dfb173e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig | |||
@@ -353,6 +353,16 @@ config VMWARE_BALLOON | |||
353 | To compile this driver as a module, choose M here: the | 353 | To compile this driver as a module, choose M here: the |
354 | module will be called vmware_balloon. | 354 | module will be called vmware_balloon. |
355 | 355 | ||
356 | config ARM_CHARLCD | ||
357 | bool "ARM Ltd. Character LCD Driver" | ||
358 | depends on PLAT_VERSATILE | ||
359 | help | ||
360 | This is a driver for the character LCD found on the ARM Ltd. | ||
361 | Versatile and RealView Platform Baseboards. It doesn't do | ||
362 | very much more than display the text "ARM Linux" on the first | ||
363 | line and the Linux version on the second line, but that's | ||
364 | still useful. | ||
365 | |||
356 | source "drivers/misc/c2port/Kconfig" | 366 | source "drivers/misc/c2port/Kconfig" |
357 | source "drivers/misc/eeprom/Kconfig" | 367 | source "drivers/misc/eeprom/Kconfig" |
358 | source "drivers/misc/cb710/Kconfig" | 368 | source "drivers/misc/cb710/Kconfig" |
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 6ed06a19474a..67552d6e9327 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile | |||
@@ -31,3 +31,4 @@ obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ | |||
31 | obj-y += eeprom/ | 31 | obj-y += eeprom/ |
32 | obj-y += cb710/ | 32 | obj-y += cb710/ |
33 | obj-$(CONFIG_VMWARE_BALLOON) += vmware_balloon.o | 33 | obj-$(CONFIG_VMWARE_BALLOON) += vmware_balloon.o |
34 | obj-$(CONFIG_ARM_CHARLCD) += arm-charlcd.o | ||
diff --git a/drivers/misc/arm-charlcd.c b/drivers/misc/arm-charlcd.c new file mode 100644 index 000000000000..9e3879ef58f2 --- /dev/null +++ b/drivers/misc/arm-charlcd.c | |||
@@ -0,0 +1,396 @@ | |||
1 | /* | ||
2 | * Driver for the on-board character LCD found on some ARM reference boards | ||
3 | * This is basically an Hitachi HD44780 LCD with a custom IP block to drive it | ||
4 | * http://en.wikipedia.org/wiki/HD44780_Character_LCD | ||
5 | * Currently it will just display the text "ARM Linux" and the linux version | ||
6 | * | ||
7 | * License terms: GNU General Public License (GPL) version 2 | ||
8 | * Author: Linus Walleij <triad@df.lth.se> | ||
9 | */ | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/module.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/completion.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/workqueue.h> | ||
19 | #include <generated/utsrelease.h> | ||
20 | |||
21 | #define DRIVERNAME "arm-charlcd" | ||
22 | #define CHARLCD_TIMEOUT (msecs_to_jiffies(1000)) | ||
23 | |||
24 | /* Offsets to registers */ | ||
25 | #define CHAR_COM 0x00U | ||
26 | #define CHAR_DAT 0x04U | ||
27 | #define CHAR_RD 0x08U | ||
28 | #define CHAR_RAW 0x0CU | ||
29 | #define CHAR_MASK 0x10U | ||
30 | #define CHAR_STAT 0x14U | ||
31 | |||
32 | #define CHAR_RAW_CLEAR 0x00000000U | ||
33 | #define CHAR_RAW_VALID 0x00000100U | ||
34 | |||
35 | /* Hitachi HD44780 display commands */ | ||
36 | #define HD_CLEAR 0x01U | ||
37 | #define HD_HOME 0x02U | ||
38 | #define HD_ENTRYMODE 0x04U | ||
39 | #define HD_ENTRYMODE_INCREMENT 0x02U | ||
40 | #define HD_ENTRYMODE_SHIFT 0x01U | ||
41 | #define HD_DISPCTRL 0x08U | ||
42 | #define HD_DISPCTRL_ON 0x04U | ||
43 | #define HD_DISPCTRL_CURSOR_ON 0x02U | ||
44 | #define HD_DISPCTRL_CURSOR_BLINK 0x01U | ||
45 | #define HD_CRSR_SHIFT 0x10U | ||
46 | #define HD_CRSR_SHIFT_DISPLAY 0x08U | ||
47 | #define HD_CRSR_SHIFT_DISPLAY_RIGHT 0x04U | ||
48 | #define HD_FUNCSET 0x20U | ||
49 | #define HD_FUNCSET_8BIT 0x10U | ||
50 | #define HD_FUNCSET_2_LINES 0x08U | ||
51 | #define HD_FUNCSET_FONT_5X10 0x04U | ||
52 | #define HD_SET_CGRAM 0x40U | ||
53 | #define HD_SET_DDRAM 0x80U | ||
54 | #define HD_BUSY_FLAG 0x80U | ||
55 | |||
56 | /** | ||
57 | * @dev: a pointer back to containing device | ||
58 | * @phybase: the offset to the controller in physical memory | ||
59 | * @physize: the size of the physical page | ||
60 | * @virtbase: the offset to the controller in virtual memory | ||
61 | * @irq: reserved interrupt number | ||
62 | * @complete: completion structure for the last LCD command | ||
63 | */ | ||
64 | struct charlcd { | ||
65 | struct device *dev; | ||
66 | u32 phybase; | ||
67 | u32 physize; | ||
68 | void __iomem *virtbase; | ||
69 | int irq; | ||
70 | struct completion complete; | ||
71 | struct delayed_work init_work; | ||
72 | }; | ||
73 | |||
74 | static irqreturn_t charlcd_interrupt(int irq, void *data) | ||
75 | { | ||
76 | struct charlcd *lcd = data; | ||
77 | u8 status; | ||
78 | |||
79 | status = readl(lcd->virtbase + CHAR_STAT) & 0x01; | ||
80 | /* Clear IRQ */ | ||
81 | writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); | ||
82 | if (status) | ||
83 | complete(&lcd->complete); | ||
84 | else | ||
85 | dev_info(lcd->dev, "Spurious IRQ (%02x)\n", status); | ||
86 | return IRQ_HANDLED; | ||
87 | } | ||
88 | |||
89 | |||
90 | static void charlcd_wait_complete_irq(struct charlcd *lcd) | ||
91 | { | ||
92 | int ret; | ||
93 | |||
94 | ret = wait_for_completion_interruptible_timeout(&lcd->complete, | ||
95 | CHARLCD_TIMEOUT); | ||
96 | /* Disable IRQ after completion */ | ||
97 | writel(0x00, lcd->virtbase + CHAR_MASK); | ||
98 | |||
99 | if (ret < 0) { | ||
100 | dev_err(lcd->dev, | ||
101 | "wait_for_completion_interruptible_timeout() " | ||
102 | "returned %d waiting for ready\n", ret); | ||
103 | return; | ||
104 | } | ||
105 | |||
106 | if (ret == 0) { | ||
107 | dev_err(lcd->dev, "charlcd controller timed out " | ||
108 | "waiting for ready\n"); | ||
109 | return; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | static u8 charlcd_4bit_read_char(struct charlcd *lcd) | ||
114 | { | ||
115 | u8 data; | ||
116 | u32 val; | ||
117 | int i; | ||
118 | |||
119 | /* If we can, use an IRQ to wait for the data, else poll */ | ||
120 | if (lcd->irq >= 0) | ||
121 | charlcd_wait_complete_irq(lcd); | ||
122 | else { | ||
123 | i = 0; | ||
124 | val = 0; | ||
125 | while (!(val & CHAR_RAW_VALID) && i < 10) { | ||
126 | udelay(100); | ||
127 | val = readl(lcd->virtbase + CHAR_RAW); | ||
128 | i++; | ||
129 | } | ||
130 | |||
131 | writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); | ||
132 | } | ||
133 | msleep(1); | ||
134 | |||
135 | /* Read the 4 high bits of the data */ | ||
136 | data = readl(lcd->virtbase + CHAR_RD) & 0xf0; | ||
137 | |||
138 | /* | ||
139 | * The second read for the low bits does not trigger an IRQ | ||
140 | * so in this case we have to poll for the 4 lower bits | ||
141 | */ | ||
142 | i = 0; | ||
143 | val = 0; | ||
144 | while (!(val & CHAR_RAW_VALID) && i < 10) { | ||
145 | udelay(100); | ||
146 | val = readl(lcd->virtbase + CHAR_RAW); | ||
147 | i++; | ||
148 | } | ||
149 | writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); | ||
150 | msleep(1); | ||
151 | |||
152 | /* Read the 4 low bits of the data */ | ||
153 | data |= (readl(lcd->virtbase + CHAR_RD) >> 4) & 0x0f; | ||
154 | |||
155 | return data; | ||
156 | } | ||
157 | |||
158 | static bool charlcd_4bit_read_bf(struct charlcd *lcd) | ||
159 | { | ||
160 | if (lcd->irq >= 0) { | ||
161 | /* | ||
162 | * If we'll use IRQs to wait for the busyflag, clear any | ||
163 | * pending flag and enable IRQ | ||
164 | */ | ||
165 | writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); | ||
166 | init_completion(&lcd->complete); | ||
167 | writel(0x01, lcd->virtbase + CHAR_MASK); | ||
168 | } | ||
169 | readl(lcd->virtbase + CHAR_COM); | ||
170 | return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false; | ||
171 | } | ||
172 | |||
173 | static void charlcd_4bit_wait_busy(struct charlcd *lcd) | ||
174 | { | ||
175 | int retries = 50; | ||
176 | |||
177 | udelay(100); | ||
178 | while (charlcd_4bit_read_bf(lcd) && retries) | ||
179 | retries--; | ||
180 | if (!retries) | ||
181 | dev_err(lcd->dev, "timeout waiting for busyflag\n"); | ||
182 | } | ||
183 | |||
184 | static void charlcd_4bit_command(struct charlcd *lcd, u8 cmd) | ||
185 | { | ||
186 | u32 cmdlo = (cmd << 4) & 0xf0; | ||
187 | u32 cmdhi = (cmd & 0xf0); | ||
188 | |||
189 | writel(cmdhi, lcd->virtbase + CHAR_COM); | ||
190 | udelay(10); | ||
191 | writel(cmdlo, lcd->virtbase + CHAR_COM); | ||
192 | charlcd_4bit_wait_busy(lcd); | ||
193 | } | ||
194 | |||
195 | static void charlcd_4bit_char(struct charlcd *lcd, u8 ch) | ||
196 | { | ||
197 | u32 chlo = (ch << 4) & 0xf0; | ||
198 | u32 chhi = (ch & 0xf0); | ||
199 | |||
200 | writel(chhi, lcd->virtbase + CHAR_DAT); | ||
201 | udelay(10); | ||
202 | writel(chlo, lcd->virtbase + CHAR_DAT); | ||
203 | charlcd_4bit_wait_busy(lcd); | ||
204 | } | ||
205 | |||
206 | static void charlcd_4bit_print(struct charlcd *lcd, int line, const char *str) | ||
207 | { | ||
208 | u8 offset; | ||
209 | int i; | ||
210 | |||
211 | /* | ||
212 | * We support line 0, 1 | ||
213 | * Line 1 runs from 0x00..0x27 | ||
214 | * Line 2 runs from 0x28..0x4f | ||
215 | */ | ||
216 | if (line == 0) | ||
217 | offset = 0; | ||
218 | else if (line == 1) | ||
219 | offset = 0x28; | ||
220 | else | ||
221 | return; | ||
222 | |||
223 | /* Set offset */ | ||
224 | charlcd_4bit_command(lcd, HD_SET_DDRAM | offset); | ||
225 | |||
226 | /* Send string */ | ||
227 | for (i = 0; i < strlen(str) && i < 0x28; i++) | ||
228 | charlcd_4bit_char(lcd, str[i]); | ||
229 | } | ||
230 | |||
231 | static void charlcd_4bit_init(struct charlcd *lcd) | ||
232 | { | ||
233 | /* These commands cannot be checked with the busy flag */ | ||
234 | writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); | ||
235 | msleep(5); | ||
236 | writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); | ||
237 | udelay(100); | ||
238 | writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); | ||
239 | udelay(100); | ||
240 | /* Go to 4bit mode */ | ||
241 | writel(HD_FUNCSET, lcd->virtbase + CHAR_COM); | ||
242 | udelay(100); | ||
243 | /* | ||
244 | * 4bit mode, 2 lines, 5x8 font, after this the number of lines | ||
245 | * and the font cannot be changed until the next initialization sequence | ||
246 | */ | ||
247 | charlcd_4bit_command(lcd, HD_FUNCSET | HD_FUNCSET_2_LINES); | ||
248 | charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON); | ||
249 | charlcd_4bit_command(lcd, HD_ENTRYMODE | HD_ENTRYMODE_INCREMENT); | ||
250 | charlcd_4bit_command(lcd, HD_CLEAR); | ||
251 | charlcd_4bit_command(lcd, HD_HOME); | ||
252 | /* Put something useful in the display */ | ||
253 | charlcd_4bit_print(lcd, 0, "ARM Linux"); | ||
254 | charlcd_4bit_print(lcd, 1, UTS_RELEASE); | ||
255 | } | ||
256 | |||
257 | static void charlcd_init_work(struct work_struct *work) | ||
258 | { | ||
259 | struct charlcd *lcd = | ||
260 | container_of(work, struct charlcd, init_work.work); | ||
261 | |||
262 | charlcd_4bit_init(lcd); | ||
263 | } | ||
264 | |||
265 | static int __init charlcd_probe(struct platform_device *pdev) | ||
266 | { | ||
267 | int ret; | ||
268 | struct charlcd *lcd; | ||
269 | struct resource *res; | ||
270 | |||
271 | lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL); | ||
272 | if (!lcd) | ||
273 | return -ENOMEM; | ||
274 | |||
275 | lcd->dev = &pdev->dev; | ||
276 | |||
277 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
278 | if (!res) { | ||
279 | ret = -ENOENT; | ||
280 | goto out_no_resource; | ||
281 | } | ||
282 | lcd->phybase = res->start; | ||
283 | lcd->physize = resource_size(res); | ||
284 | |||
285 | if (request_mem_region(lcd->phybase, lcd->physize, | ||
286 | DRIVERNAME) == NULL) { | ||
287 | ret = -EBUSY; | ||
288 | goto out_no_memregion; | ||
289 | } | ||
290 | |||
291 | lcd->virtbase = ioremap(lcd->phybase, lcd->physize); | ||
292 | if (!lcd->virtbase) { | ||
293 | ret = -ENOMEM; | ||
294 | goto out_no_remap; | ||
295 | } | ||
296 | |||
297 | lcd->irq = platform_get_irq(pdev, 0); | ||
298 | /* If no IRQ is supplied, we'll survive without it */ | ||
299 | if (lcd->irq >= 0) { | ||
300 | if (request_irq(lcd->irq, charlcd_interrupt, IRQF_DISABLED, | ||
301 | DRIVERNAME, lcd)) { | ||
302 | ret = -EIO; | ||
303 | goto out_no_irq; | ||
304 | } | ||
305 | } | ||
306 | |||
307 | platform_set_drvdata(pdev, lcd); | ||
308 | |||
309 | /* | ||
310 | * Initialize the display in a delayed work, because | ||
311 | * it is VERY slow and would slow down the boot of the system. | ||
312 | */ | ||
313 | INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work); | ||
314 | schedule_delayed_work(&lcd->init_work, 0); | ||
315 | |||
316 | dev_info(&pdev->dev, "initalized ARM character LCD at %08x\n", | ||
317 | lcd->phybase); | ||
318 | |||
319 | return 0; | ||
320 | |||
321 | out_no_irq: | ||
322 | iounmap(lcd->virtbase); | ||
323 | out_no_remap: | ||
324 | platform_set_drvdata(pdev, NULL); | ||
325 | out_no_memregion: | ||
326 | release_mem_region(lcd->phybase, SZ_4K); | ||
327 | out_no_resource: | ||
328 | kfree(lcd); | ||
329 | return ret; | ||
330 | } | ||
331 | |||
332 | static int __exit charlcd_remove(struct platform_device *pdev) | ||
333 | { | ||
334 | struct charlcd *lcd = platform_get_drvdata(pdev); | ||
335 | |||
336 | if (lcd) { | ||
337 | free_irq(lcd->irq, lcd); | ||
338 | iounmap(lcd->virtbase); | ||
339 | release_mem_region(lcd->phybase, lcd->physize); | ||
340 | platform_set_drvdata(pdev, NULL); | ||
341 | kfree(lcd); | ||
342 | } | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static int charlcd_suspend(struct device *dev) | ||
348 | { | ||
349 | struct platform_device *pdev = to_platform_device(dev); | ||
350 | struct charlcd *lcd = platform_get_drvdata(pdev); | ||
351 | |||
352 | /* Power the display off */ | ||
353 | charlcd_4bit_command(lcd, HD_DISPCTRL); | ||
354 | return 0; | ||
355 | } | ||
356 | |||
357 | static int charlcd_resume(struct device *dev) | ||
358 | { | ||
359 | struct platform_device *pdev = to_platform_device(dev); | ||
360 | struct charlcd *lcd = platform_get_drvdata(pdev); | ||
361 | |||
362 | /* Turn the display back on */ | ||
363 | charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON); | ||
364 | return 0; | ||
365 | } | ||
366 | |||
367 | static const struct dev_pm_ops charlcd_pm_ops = { | ||
368 | .suspend = charlcd_suspend, | ||
369 | .resume = charlcd_resume, | ||
370 | }; | ||
371 | |||
372 | static struct platform_driver charlcd_driver = { | ||
373 | .driver = { | ||
374 | .name = DRIVERNAME, | ||
375 | .owner = THIS_MODULE, | ||
376 | .pm = &charlcd_pm_ops, | ||
377 | }, | ||
378 | .remove = __exit_p(charlcd_remove), | ||
379 | }; | ||
380 | |||
381 | static int __init charlcd_init(void) | ||
382 | { | ||
383 | return platform_driver_probe(&charlcd_driver, charlcd_probe); | ||
384 | } | ||
385 | |||
386 | static void __exit charlcd_exit(void) | ||
387 | { | ||
388 | platform_driver_unregister(&charlcd_driver); | ||
389 | } | ||
390 | |||
391 | module_init(charlcd_init); | ||
392 | module_exit(charlcd_exit); | ||
393 | |||
394 | MODULE_AUTHOR("Linus Walleij <triad@df.lth.se>"); | ||
395 | MODULE_DESCRIPTION("ARM Character LCD Driver"); | ||
396 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index eaa79c8a9b8c..93ead19507b6 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -76,11 +76,12 @@ | |||
76 | static const char driver_name [] = "at91_udc"; | 76 | static const char driver_name [] = "at91_udc"; |
77 | static const char ep0name[] = "ep0"; | 77 | static const char ep0name[] = "ep0"; |
78 | 78 | ||
79 | #define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) | ||
79 | 80 | ||
80 | #define at91_udp_read(dev, reg) \ | 81 | #define at91_udp_read(udc, reg) \ |
81 | __raw_readl((dev)->udp_baseaddr + (reg)) | 82 | __raw_readl((udc)->udp_baseaddr + (reg)) |
82 | #define at91_udp_write(dev, reg, val) \ | 83 | #define at91_udp_write(udc, reg, val) \ |
83 | __raw_writel((val), (dev)->udp_baseaddr + (reg)) | 84 | __raw_writel((val), (udc)->udp_baseaddr + (reg)) |
84 | 85 | ||
85 | /*-------------------------------------------------------------------------*/ | 86 | /*-------------------------------------------------------------------------*/ |
86 | 87 | ||
@@ -102,8 +103,9 @@ static void proc_ep_show(struct seq_file *s, struct at91_ep *ep) | |||
102 | u32 csr; | 103 | u32 csr; |
103 | struct at91_request *req; | 104 | struct at91_request *req; |
104 | unsigned long flags; | 105 | unsigned long flags; |
106 | struct at91_udc *udc = ep->udc; | ||
105 | 107 | ||
106 | local_irq_save(flags); | 108 | spin_lock_irqsave(&udc->lock, flags); |
107 | 109 | ||
108 | csr = __raw_readl(ep->creg); | 110 | csr = __raw_readl(ep->creg); |
109 | 111 | ||
@@ -147,7 +149,7 @@ static void proc_ep_show(struct seq_file *s, struct at91_ep *ep) | |||
147 | &req->req, length, | 149 | &req->req, length, |
148 | req->req.length, req->req.buf); | 150 | req->req.length, req->req.buf); |
149 | } | 151 | } |
150 | local_irq_restore(flags); | 152 | spin_unlock_irqrestore(&udc->lock, flags); |
151 | } | 153 | } |
152 | 154 | ||
153 | static void proc_irq_show(struct seq_file *s, const char *label, u32 mask) | 155 | static void proc_irq_show(struct seq_file *s, const char *label, u32 mask) |
@@ -272,7 +274,9 @@ static void done(struct at91_ep *ep, struct at91_request *req, int status) | |||
272 | VDBG("%s done %p, status %d\n", ep->ep.name, req, status); | 274 | VDBG("%s done %p, status %d\n", ep->ep.name, req, status); |
273 | 275 | ||
274 | ep->stopped = 1; | 276 | ep->stopped = 1; |
277 | spin_unlock(&udc->lock); | ||
275 | req->req.complete(&ep->ep, &req->req); | 278 | req->req.complete(&ep->ep, &req->req); |
279 | spin_lock(&udc->lock); | ||
276 | ep->stopped = stopped; | 280 | ep->stopped = stopped; |
277 | 281 | ||
278 | /* ep0 is always ready; other endpoints need a non-empty queue */ | 282 | /* ep0 is always ready; other endpoints need a non-empty queue */ |
@@ -472,7 +476,7 @@ static int at91_ep_enable(struct usb_ep *_ep, | |||
472 | const struct usb_endpoint_descriptor *desc) | 476 | const struct usb_endpoint_descriptor *desc) |
473 | { | 477 | { |
474 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); | 478 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); |
475 | struct at91_udc *dev = ep->udc; | 479 | struct at91_udc *udc = ep->udc; |
476 | u16 maxpacket; | 480 | u16 maxpacket; |
477 | u32 tmp; | 481 | u32 tmp; |
478 | unsigned long flags; | 482 | unsigned long flags; |
@@ -487,7 +491,7 @@ static int at91_ep_enable(struct usb_ep *_ep, | |||
487 | return -EINVAL; | 491 | return -EINVAL; |
488 | } | 492 | } |
489 | 493 | ||
490 | if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { | 494 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { |
491 | DBG("bogus device state\n"); | 495 | DBG("bogus device state\n"); |
492 | return -ESHUTDOWN; | 496 | return -ESHUTDOWN; |
493 | } | 497 | } |
@@ -521,7 +525,7 @@ bogus_max: | |||
521 | } | 525 | } |
522 | 526 | ||
523 | ok: | 527 | ok: |
524 | local_irq_save(flags); | 528 | spin_lock_irqsave(&udc->lock, flags); |
525 | 529 | ||
526 | /* initialize endpoint to match this descriptor */ | 530 | /* initialize endpoint to match this descriptor */ |
527 | ep->is_in = usb_endpoint_dir_in(desc); | 531 | ep->is_in = usb_endpoint_dir_in(desc); |
@@ -540,10 +544,10 @@ ok: | |||
540 | * reset/init endpoint fifo. NOTE: leaves fifo_bank alone, | 544 | * reset/init endpoint fifo. NOTE: leaves fifo_bank alone, |
541 | * since endpoint resets don't reset hw pingpong state. | 545 | * since endpoint resets don't reset hw pingpong state. |
542 | */ | 546 | */ |
543 | at91_udp_write(dev, AT91_UDP_RST_EP, ep->int_mask); | 547 | at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); |
544 | at91_udp_write(dev, AT91_UDP_RST_EP, 0); | 548 | at91_udp_write(udc, AT91_UDP_RST_EP, 0); |
545 | 549 | ||
546 | local_irq_restore(flags); | 550 | spin_unlock_irqrestore(&udc->lock, flags); |
547 | return 0; | 551 | return 0; |
548 | } | 552 | } |
549 | 553 | ||
@@ -556,7 +560,7 @@ static int at91_ep_disable (struct usb_ep * _ep) | |||
556 | if (ep == &ep->udc->ep[0]) | 560 | if (ep == &ep->udc->ep[0]) |
557 | return -EINVAL; | 561 | return -EINVAL; |
558 | 562 | ||
559 | local_irq_save(flags); | 563 | spin_lock_irqsave(&udc->lock, flags); |
560 | 564 | ||
561 | nuke(ep, -ESHUTDOWN); | 565 | nuke(ep, -ESHUTDOWN); |
562 | 566 | ||
@@ -571,7 +575,7 @@ static int at91_ep_disable (struct usb_ep * _ep) | |||
571 | __raw_writel(0, ep->creg); | 575 | __raw_writel(0, ep->creg); |
572 | } | 576 | } |
573 | 577 | ||
574 | local_irq_restore(flags); | 578 | spin_unlock_irqrestore(&udc->lock, flags); |
575 | return 0; | 579 | return 0; |
576 | } | 580 | } |
577 | 581 | ||
@@ -607,7 +611,7 @@ static int at91_ep_queue(struct usb_ep *_ep, | |||
607 | { | 611 | { |
608 | struct at91_request *req; | 612 | struct at91_request *req; |
609 | struct at91_ep *ep; | 613 | struct at91_ep *ep; |
610 | struct at91_udc *dev; | 614 | struct at91_udc *udc; |
611 | int status; | 615 | int status; |
612 | unsigned long flags; | 616 | unsigned long flags; |
613 | 617 | ||
@@ -625,9 +629,9 @@ static int at91_ep_queue(struct usb_ep *_ep, | |||
625 | return -EINVAL; | 629 | return -EINVAL; |
626 | } | 630 | } |
627 | 631 | ||
628 | dev = ep->udc; | 632 | udc = ep->udc; |
629 | 633 | ||
630 | if (!dev || !dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN) { | 634 | if (!udc || !udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) { |
631 | DBG("invalid device\n"); | 635 | DBG("invalid device\n"); |
632 | return -EINVAL; | 636 | return -EINVAL; |
633 | } | 637 | } |
@@ -635,7 +639,7 @@ static int at91_ep_queue(struct usb_ep *_ep, | |||
635 | _req->status = -EINPROGRESS; | 639 | _req->status = -EINPROGRESS; |
636 | _req->actual = 0; | 640 | _req->actual = 0; |
637 | 641 | ||
638 | local_irq_save(flags); | 642 | spin_lock_irqsave(&udc->lock, flags); |
639 | 643 | ||
640 | /* try to kickstart any empty and idle queue */ | 644 | /* try to kickstart any empty and idle queue */ |
641 | if (list_empty(&ep->queue) && !ep->stopped) { | 645 | if (list_empty(&ep->queue) && !ep->stopped) { |
@@ -653,7 +657,7 @@ static int at91_ep_queue(struct usb_ep *_ep, | |||
653 | if (is_ep0) { | 657 | if (is_ep0) { |
654 | u32 tmp; | 658 | u32 tmp; |
655 | 659 | ||
656 | if (!dev->req_pending) { | 660 | if (!udc->req_pending) { |
657 | status = -EINVAL; | 661 | status = -EINVAL; |
658 | goto done; | 662 | goto done; |
659 | } | 663 | } |
@@ -662,11 +666,11 @@ static int at91_ep_queue(struct usb_ep *_ep, | |||
662 | * defer changing CONFG until after the gadget driver | 666 | * defer changing CONFG until after the gadget driver |
663 | * reconfigures the endpoints. | 667 | * reconfigures the endpoints. |
664 | */ | 668 | */ |
665 | if (dev->wait_for_config_ack) { | 669 | if (udc->wait_for_config_ack) { |
666 | tmp = at91_udp_read(dev, AT91_UDP_GLB_STAT); | 670 | tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); |
667 | tmp ^= AT91_UDP_CONFG; | 671 | tmp ^= AT91_UDP_CONFG; |
668 | VDBG("toggle config\n"); | 672 | VDBG("toggle config\n"); |
669 | at91_udp_write(dev, AT91_UDP_GLB_STAT, tmp); | 673 | at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); |
670 | } | 674 | } |
671 | if (req->req.length == 0) { | 675 | if (req->req.length == 0) { |
672 | ep0_in_status: | 676 | ep0_in_status: |
@@ -676,7 +680,7 @@ ep0_in_status: | |||
676 | tmp &= ~SET_FX; | 680 | tmp &= ~SET_FX; |
677 | tmp |= CLR_FX | AT91_UDP_TXPKTRDY; | 681 | tmp |= CLR_FX | AT91_UDP_TXPKTRDY; |
678 | __raw_writel(tmp, ep->creg); | 682 | __raw_writel(tmp, ep->creg); |
679 | dev->req_pending = 0; | 683 | udc->req_pending = 0; |
680 | goto done; | 684 | goto done; |
681 | } | 685 | } |
682 | } | 686 | } |
@@ -695,31 +699,40 @@ ep0_in_status: | |||
695 | 699 | ||
696 | if (req && !status) { | 700 | if (req && !status) { |
697 | list_add_tail (&req->queue, &ep->queue); | 701 | list_add_tail (&req->queue, &ep->queue); |
698 | at91_udp_write(dev, AT91_UDP_IER, ep->int_mask); | 702 | at91_udp_write(udc, AT91_UDP_IER, ep->int_mask); |
699 | } | 703 | } |
700 | done: | 704 | done: |
701 | local_irq_restore(flags); | 705 | spin_unlock_irqrestore(&udc->lock, flags); |
702 | return (status < 0) ? status : 0; | 706 | return (status < 0) ? status : 0; |
703 | } | 707 | } |
704 | 708 | ||
705 | static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | 709 | static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) |
706 | { | 710 | { |
707 | struct at91_ep *ep; | 711 | struct at91_ep *ep; |
708 | struct at91_request *req; | 712 | struct at91_request *req; |
713 | unsigned long flags; | ||
714 | struct at91_udc *udc; | ||
709 | 715 | ||
710 | ep = container_of(_ep, struct at91_ep, ep); | 716 | ep = container_of(_ep, struct at91_ep, ep); |
711 | if (!_ep || ep->ep.name == ep0name) | 717 | if (!_ep || ep->ep.name == ep0name) |
712 | return -EINVAL; | 718 | return -EINVAL; |
713 | 719 | ||
720 | udc = ep->udc; | ||
721 | |||
722 | spin_lock_irqsave(&udc->lock, flags); | ||
723 | |||
714 | /* make sure it's actually queued on this endpoint */ | 724 | /* make sure it's actually queued on this endpoint */ |
715 | list_for_each_entry (req, &ep->queue, queue) { | 725 | list_for_each_entry (req, &ep->queue, queue) { |
716 | if (&req->req == _req) | 726 | if (&req->req == _req) |
717 | break; | 727 | break; |
718 | } | 728 | } |
719 | if (&req->req != _req) | 729 | if (&req->req != _req) { |
730 | spin_unlock_irqrestore(&udc->lock, flags); | ||
720 | return -EINVAL; | 731 | return -EINVAL; |
732 | } | ||
721 | 733 | ||
722 | done(ep, req, -ECONNRESET); | 734 | done(ep, req, -ECONNRESET); |
735 | spin_unlock_irqrestore(&udc->lock, flags); | ||
723 | return 0; | 736 | return 0; |
724 | } | 737 | } |
725 | 738 | ||
@@ -736,7 +749,7 @@ static int at91_ep_set_halt(struct usb_ep *_ep, int value) | |||
736 | return -EINVAL; | 749 | return -EINVAL; |
737 | 750 | ||
738 | creg = ep->creg; | 751 | creg = ep->creg; |
739 | local_irq_save(flags); | 752 | spin_lock_irqsave(&udc->lock, flags); |
740 | 753 | ||
741 | csr = __raw_readl(creg); | 754 | csr = __raw_readl(creg); |
742 | 755 | ||
@@ -761,7 +774,7 @@ static int at91_ep_set_halt(struct usb_ep *_ep, int value) | |||
761 | __raw_writel(csr, creg); | 774 | __raw_writel(csr, creg); |
762 | } | 775 | } |
763 | 776 | ||
764 | local_irq_restore(flags); | 777 | spin_unlock_irqrestore(&udc->lock, flags); |
765 | return status; | 778 | return status; |
766 | } | 779 | } |
767 | 780 | ||
@@ -795,7 +808,7 @@ static int at91_wakeup(struct usb_gadget *gadget) | |||
795 | unsigned long flags; | 808 | unsigned long flags; |
796 | 809 | ||
797 | DBG("%s\n", __func__ ); | 810 | DBG("%s\n", __func__ ); |
798 | local_irq_save(flags); | 811 | spin_lock_irqsave(&udc->lock, flags); |
799 | 812 | ||
800 | if (!udc->clocked || !udc->suspended) | 813 | if (!udc->clocked || !udc->suspended) |
801 | goto done; | 814 | goto done; |
@@ -809,7 +822,7 @@ static int at91_wakeup(struct usb_gadget *gadget) | |||
809 | at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate); | 822 | at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate); |
810 | 823 | ||
811 | done: | 824 | done: |
812 | local_irq_restore(flags); | 825 | spin_unlock_irqrestore(&udc->lock, flags); |
813 | return status; | 826 | return status; |
814 | } | 827 | } |
815 | 828 | ||
@@ -851,8 +864,11 @@ static void stop_activity(struct at91_udc *udc) | |||
851 | ep->stopped = 1; | 864 | ep->stopped = 1; |
852 | nuke(ep, -ESHUTDOWN); | 865 | nuke(ep, -ESHUTDOWN); |
853 | } | 866 | } |
854 | if (driver) | 867 | if (driver) { |
868 | spin_unlock(&udc->lock); | ||
855 | driver->disconnect(&udc->gadget); | 869 | driver->disconnect(&udc->gadget); |
870 | spin_lock(&udc->lock); | ||
871 | } | ||
856 | 872 | ||
857 | udc_reinit(udc); | 873 | udc_reinit(udc); |
858 | } | 874 | } |
@@ -935,13 +951,13 @@ static int at91_vbus_session(struct usb_gadget *gadget, int is_active) | |||
935 | unsigned long flags; | 951 | unsigned long flags; |
936 | 952 | ||
937 | // VDBG("vbus %s\n", is_active ? "on" : "off"); | 953 | // VDBG("vbus %s\n", is_active ? "on" : "off"); |
938 | local_irq_save(flags); | 954 | spin_lock_irqsave(&udc->lock, flags); |
939 | udc->vbus = (is_active != 0); | 955 | udc->vbus = (is_active != 0); |
940 | if (udc->driver) | 956 | if (udc->driver) |
941 | pullup(udc, is_active); | 957 | pullup(udc, is_active); |
942 | else | 958 | else |
943 | pullup(udc, 0); | 959 | pullup(udc, 0); |
944 | local_irq_restore(flags); | 960 | spin_unlock_irqrestore(&udc->lock, flags); |
945 | return 0; | 961 | return 0; |
946 | } | 962 | } |
947 | 963 | ||
@@ -950,10 +966,10 @@ static int at91_pullup(struct usb_gadget *gadget, int is_on) | |||
950 | struct at91_udc *udc = to_udc(gadget); | 966 | struct at91_udc *udc = to_udc(gadget); |
951 | unsigned long flags; | 967 | unsigned long flags; |
952 | 968 | ||
953 | local_irq_save(flags); | 969 | spin_lock_irqsave(&udc->lock, flags); |
954 | udc->enabled = is_on = !!is_on; | 970 | udc->enabled = is_on = !!is_on; |
955 | pullup(udc, is_on); | 971 | pullup(udc, is_on); |
956 | local_irq_restore(flags); | 972 | spin_unlock_irqrestore(&udc->lock, flags); |
957 | return 0; | 973 | return 0; |
958 | } | 974 | } |
959 | 975 | ||
@@ -962,9 +978,9 @@ static int at91_set_selfpowered(struct usb_gadget *gadget, int is_on) | |||
962 | struct at91_udc *udc = to_udc(gadget); | 978 | struct at91_udc *udc = to_udc(gadget); |
963 | unsigned long flags; | 979 | unsigned long flags; |
964 | 980 | ||
965 | local_irq_save(flags); | 981 | spin_lock_irqsave(&udc->lock, flags); |
966 | udc->selfpowered = (is_on != 0); | 982 | udc->selfpowered = (is_on != 0); |
967 | local_irq_restore(flags); | 983 | spin_unlock_irqrestore(&udc->lock, flags); |
968 | return 0; | 984 | return 0; |
969 | } | 985 | } |
970 | 986 | ||
@@ -1226,8 +1242,11 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1226 | #undef w_length | 1242 | #undef w_length |
1227 | 1243 | ||
1228 | /* pass request up to the gadget driver */ | 1244 | /* pass request up to the gadget driver */ |
1229 | if (udc->driver) | 1245 | if (udc->driver) { |
1246 | spin_unlock(&udc->lock); | ||
1230 | status = udc->driver->setup(&udc->gadget, &pkt.r); | 1247 | status = udc->driver->setup(&udc->gadget, &pkt.r); |
1248 | spin_lock(&udc->lock); | ||
1249 | } | ||
1231 | else | 1250 | else |
1232 | status = -ENODEV; | 1251 | status = -ENODEV; |
1233 | if (status < 0) { | 1252 | if (status < 0) { |
@@ -1378,6 +1397,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1378 | struct at91_udc *udc = _udc; | 1397 | struct at91_udc *udc = _udc; |
1379 | u32 rescans = 5; | 1398 | u32 rescans = 5; |
1380 | int disable_clock = 0; | 1399 | int disable_clock = 0; |
1400 | unsigned long flags; | ||
1401 | |||
1402 | spin_lock_irqsave(&udc->lock, flags); | ||
1381 | 1403 | ||
1382 | if (!udc->clocked) { | 1404 | if (!udc->clocked) { |
1383 | clk_on(udc); | 1405 | clk_on(udc); |
@@ -1433,8 +1455,11 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1433 | * and then into standby to avoid drawing more than | 1455 | * and then into standby to avoid drawing more than |
1434 | * 500uA power (2500uA for some high-power configs). | 1456 | * 500uA power (2500uA for some high-power configs). |
1435 | */ | 1457 | */ |
1436 | if (udc->driver && udc->driver->suspend) | 1458 | if (udc->driver && udc->driver->suspend) { |
1459 | spin_unlock(&udc->lock); | ||
1437 | udc->driver->suspend(&udc->gadget); | 1460 | udc->driver->suspend(&udc->gadget); |
1461 | spin_lock(&udc->lock); | ||
1462 | } | ||
1438 | 1463 | ||
1439 | /* host initiated resume */ | 1464 | /* host initiated resume */ |
1440 | } else if (status & AT91_UDP_RXRSM) { | 1465 | } else if (status & AT91_UDP_RXRSM) { |
@@ -1451,8 +1476,11 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1451 | * would normally want to switch out of slow clock | 1476 | * would normally want to switch out of slow clock |
1452 | * mode into normal mode. | 1477 | * mode into normal mode. |
1453 | */ | 1478 | */ |
1454 | if (udc->driver && udc->driver->resume) | 1479 | if (udc->driver && udc->driver->resume) { |
1480 | spin_unlock(&udc->lock); | ||
1455 | udc->driver->resume(&udc->gadget); | 1481 | udc->driver->resume(&udc->gadget); |
1482 | spin_lock(&udc->lock); | ||
1483 | } | ||
1456 | 1484 | ||
1457 | /* endpoint IRQs are cleared by handling them */ | 1485 | /* endpoint IRQs are cleared by handling them */ |
1458 | } else { | 1486 | } else { |
@@ -1474,6 +1502,8 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1474 | if (disable_clock) | 1502 | if (disable_clock) |
1475 | clk_off(udc); | 1503 | clk_off(udc); |
1476 | 1504 | ||
1505 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1506 | |||
1477 | return IRQ_HANDLED; | 1507 | return IRQ_HANDLED; |
1478 | } | 1508 | } |
1479 | 1509 | ||
@@ -1556,24 +1586,53 @@ static struct at91_udc controller = { | |||
1556 | /* ep6 and ep7 are also reserved (custom silicon might use them) */ | 1586 | /* ep6 and ep7 are also reserved (custom silicon might use them) */ |
1557 | }; | 1587 | }; |
1558 | 1588 | ||
1589 | static void at91_vbus_update(struct at91_udc *udc, unsigned value) | ||
1590 | { | ||
1591 | value ^= udc->board.vbus_active_low; | ||
1592 | if (value != udc->vbus) | ||
1593 | at91_vbus_session(&udc->gadget, value); | ||
1594 | } | ||
1595 | |||
1559 | static irqreturn_t at91_vbus_irq(int irq, void *_udc) | 1596 | static irqreturn_t at91_vbus_irq(int irq, void *_udc) |
1560 | { | 1597 | { |
1561 | struct at91_udc *udc = _udc; | 1598 | struct at91_udc *udc = _udc; |
1562 | unsigned value; | ||
1563 | 1599 | ||
1564 | /* vbus needs at least brief debouncing */ | 1600 | /* vbus needs at least brief debouncing */ |
1565 | udelay(10); | 1601 | udelay(10); |
1566 | value = gpio_get_value(udc->board.vbus_pin); | 1602 | at91_vbus_update(udc, gpio_get_value(udc->board.vbus_pin)); |
1567 | if (value != udc->vbus) | ||
1568 | at91_vbus_session(&udc->gadget, value); | ||
1569 | 1603 | ||
1570 | return IRQ_HANDLED; | 1604 | return IRQ_HANDLED; |
1571 | } | 1605 | } |
1572 | 1606 | ||
1607 | static void at91_vbus_timer_work(struct work_struct *work) | ||
1608 | { | ||
1609 | struct at91_udc *udc = container_of(work, struct at91_udc, | ||
1610 | vbus_timer_work); | ||
1611 | |||
1612 | at91_vbus_update(udc, gpio_get_value_cansleep(udc->board.vbus_pin)); | ||
1613 | |||
1614 | if (!timer_pending(&udc->vbus_timer)) | ||
1615 | mod_timer(&udc->vbus_timer, jiffies + VBUS_POLL_TIMEOUT); | ||
1616 | } | ||
1617 | |||
1618 | static void at91_vbus_timer(unsigned long data) | ||
1619 | { | ||
1620 | struct at91_udc *udc = (struct at91_udc *)data; | ||
1621 | |||
1622 | /* | ||
1623 | * If we are polling vbus it is likely that the gpio is on an | ||
1624 | * bus such as i2c or spi which may sleep, so schedule some work | ||
1625 | * to read the vbus gpio | ||
1626 | */ | ||
1627 | if (!work_pending(&udc->vbus_timer_work)) | ||
1628 | schedule_work(&udc->vbus_timer_work); | ||
1629 | } | ||
1630 | |||
1573 | int usb_gadget_register_driver (struct usb_gadget_driver *driver) | 1631 | int usb_gadget_register_driver (struct usb_gadget_driver *driver) |
1574 | { | 1632 | { |
1575 | struct at91_udc *udc = &controller; | 1633 | struct at91_udc *udc = &controller; |
1576 | int retval; | 1634 | int retval; |
1635 | unsigned long flags; | ||
1577 | 1636 | ||
1578 | if (!driver | 1637 | if (!driver |
1579 | || driver->speed < USB_SPEED_FULL | 1638 | || driver->speed < USB_SPEED_FULL |
@@ -1605,9 +1664,9 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
1605 | return retval; | 1664 | return retval; |
1606 | } | 1665 | } |
1607 | 1666 | ||
1608 | local_irq_disable(); | 1667 | spin_lock_irqsave(&udc->lock, flags); |
1609 | pullup(udc, 1); | 1668 | pullup(udc, 1); |
1610 | local_irq_enable(); | 1669 | spin_unlock_irqrestore(&udc->lock, flags); |
1611 | 1670 | ||
1612 | DBG("bound to %s\n", driver->driver.name); | 1671 | DBG("bound to %s\n", driver->driver.name); |
1613 | return 0; | 1672 | return 0; |
@@ -1617,15 +1676,16 @@ EXPORT_SYMBOL (usb_gadget_register_driver); | |||
1617 | int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | 1676 | int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) |
1618 | { | 1677 | { |
1619 | struct at91_udc *udc = &controller; | 1678 | struct at91_udc *udc = &controller; |
1679 | unsigned long flags; | ||
1620 | 1680 | ||
1621 | if (!driver || driver != udc->driver || !driver->unbind) | 1681 | if (!driver || driver != udc->driver || !driver->unbind) |
1622 | return -EINVAL; | 1682 | return -EINVAL; |
1623 | 1683 | ||
1624 | local_irq_disable(); | 1684 | spin_lock_irqsave(&udc->lock, flags); |
1625 | udc->enabled = 0; | 1685 | udc->enabled = 0; |
1626 | at91_udp_write(udc, AT91_UDP_IDR, ~0); | 1686 | at91_udp_write(udc, AT91_UDP_IDR, ~0); |
1627 | pullup(udc, 0); | 1687 | pullup(udc, 0); |
1628 | local_irq_enable(); | 1688 | spin_unlock_irqrestore(&udc->lock, flags); |
1629 | 1689 | ||
1630 | driver->unbind(&udc->gadget); | 1690 | driver->unbind(&udc->gadget); |
1631 | udc->gadget.dev.driver = NULL; | 1691 | udc->gadget.dev.driver = NULL; |
@@ -1641,8 +1701,13 @@ EXPORT_SYMBOL (usb_gadget_unregister_driver); | |||
1641 | 1701 | ||
1642 | static void at91udc_shutdown(struct platform_device *dev) | 1702 | static void at91udc_shutdown(struct platform_device *dev) |
1643 | { | 1703 | { |
1704 | struct at91_udc *udc = platform_get_drvdata(dev); | ||
1705 | unsigned long flags; | ||
1706 | |||
1644 | /* force disconnect on reboot */ | 1707 | /* force disconnect on reboot */ |
1708 | spin_lock_irqsave(&udc->lock, flags); | ||
1645 | pullup(platform_get_drvdata(dev), 0); | 1709 | pullup(platform_get_drvdata(dev), 0); |
1710 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1646 | } | 1711 | } |
1647 | 1712 | ||
1648 | static int __init at91udc_probe(struct platform_device *pdev) | 1713 | static int __init at91udc_probe(struct platform_device *pdev) |
@@ -1683,6 +1748,7 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1683 | udc->board = *(struct at91_udc_data *) dev->platform_data; | 1748 | udc->board = *(struct at91_udc_data *) dev->platform_data; |
1684 | udc->pdev = pdev; | 1749 | udc->pdev = pdev; |
1685 | udc->enabled = 0; | 1750 | udc->enabled = 0; |
1751 | spin_lock_init(&udc->lock); | ||
1686 | 1752 | ||
1687 | /* rm9200 needs manual D+ pullup; off by default */ | 1753 | /* rm9200 needs manual D+ pullup; off by default */ |
1688 | if (cpu_is_at91rm9200()) { | 1754 | if (cpu_is_at91rm9200()) { |
@@ -1763,13 +1829,23 @@ static int __init at91udc_probe(struct platform_device *pdev) | |||
1763 | * Get the initial state of VBUS - we cannot expect | 1829 | * Get the initial state of VBUS - we cannot expect |
1764 | * a pending interrupt. | 1830 | * a pending interrupt. |
1765 | */ | 1831 | */ |
1766 | udc->vbus = gpio_get_value(udc->board.vbus_pin); | 1832 | udc->vbus = gpio_get_value_cansleep(udc->board.vbus_pin) ^ |
1767 | if (request_irq(udc->board.vbus_pin, at91_vbus_irq, | 1833 | udc->board.vbus_active_low; |
1768 | IRQF_DISABLED, driver_name, udc)) { | 1834 | |
1769 | DBG("request vbus irq %d failed\n", | 1835 | if (udc->board.vbus_polled) { |
1770 | udc->board.vbus_pin); | 1836 | INIT_WORK(&udc->vbus_timer_work, at91_vbus_timer_work); |
1771 | retval = -EBUSY; | 1837 | setup_timer(&udc->vbus_timer, at91_vbus_timer, |
1772 | goto fail3; | 1838 | (unsigned long)udc); |
1839 | mod_timer(&udc->vbus_timer, | ||
1840 | jiffies + VBUS_POLL_TIMEOUT); | ||
1841 | } else { | ||
1842 | if (request_irq(udc->board.vbus_pin, at91_vbus_irq, | ||
1843 | IRQF_DISABLED, driver_name, udc)) { | ||
1844 | DBG("request vbus irq %d failed\n", | ||
1845 | udc->board.vbus_pin); | ||
1846 | retval = -EBUSY; | ||
1847 | goto fail3; | ||
1848 | } | ||
1773 | } | 1849 | } |
1774 | } else { | 1850 | } else { |
1775 | DBG("no VBUS detection, assuming always-on\n"); | 1851 | DBG("no VBUS detection, assuming always-on\n"); |
@@ -1804,13 +1880,16 @@ static int __exit at91udc_remove(struct platform_device *pdev) | |||
1804 | { | 1880 | { |
1805 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1881 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1806 | struct resource *res; | 1882 | struct resource *res; |
1883 | unsigned long flags; | ||
1807 | 1884 | ||
1808 | DBG("remove\n"); | 1885 | DBG("remove\n"); |
1809 | 1886 | ||
1810 | if (udc->driver) | 1887 | if (udc->driver) |
1811 | return -EBUSY; | 1888 | return -EBUSY; |
1812 | 1889 | ||
1890 | spin_lock_irqsave(&udc->lock, flags); | ||
1813 | pullup(udc, 0); | 1891 | pullup(udc, 0); |
1892 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1814 | 1893 | ||
1815 | device_init_wakeup(&pdev->dev, 0); | 1894 | device_init_wakeup(&pdev->dev, 0); |
1816 | remove_debug_file(udc); | 1895 | remove_debug_file(udc); |
@@ -1840,6 +1919,7 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1840 | { | 1919 | { |
1841 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1920 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1842 | int wake = udc->driver && device_may_wakeup(&pdev->dev); | 1921 | int wake = udc->driver && device_may_wakeup(&pdev->dev); |
1922 | unsigned long flags; | ||
1843 | 1923 | ||
1844 | /* Unless we can act normally to the host (letting it wake us up | 1924 | /* Unless we can act normally to the host (letting it wake us up |
1845 | * whenever it has work for us) force disconnect. Wakeup requires | 1925 | * whenever it has work for us) force disconnect. Wakeup requires |
@@ -1849,13 +1929,15 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1849 | if ((!udc->suspended && udc->addr) | 1929 | if ((!udc->suspended && udc->addr) |
1850 | || !wake | 1930 | || !wake |
1851 | || at91_suspend_entering_slow_clock()) { | 1931 | || at91_suspend_entering_slow_clock()) { |
1932 | spin_lock_irqsave(&udc->lock, flags); | ||
1852 | pullup(udc, 0); | 1933 | pullup(udc, 0); |
1853 | wake = 0; | 1934 | wake = 0; |
1935 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1854 | } else | 1936 | } else |
1855 | enable_irq_wake(udc->udp_irq); | 1937 | enable_irq_wake(udc->udp_irq); |
1856 | 1938 | ||
1857 | udc->active_suspend = wake; | 1939 | udc->active_suspend = wake; |
1858 | if (udc->board.vbus_pin > 0 && wake) | 1940 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && wake) |
1859 | enable_irq_wake(udc->board.vbus_pin); | 1941 | enable_irq_wake(udc->board.vbus_pin); |
1860 | return 0; | 1942 | return 0; |
1861 | } | 1943 | } |
@@ -1863,15 +1945,20 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1863 | static int at91udc_resume(struct platform_device *pdev) | 1945 | static int at91udc_resume(struct platform_device *pdev) |
1864 | { | 1946 | { |
1865 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1947 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1948 | unsigned long flags; | ||
1866 | 1949 | ||
1867 | if (udc->board.vbus_pin > 0 && udc->active_suspend) | 1950 | if (udc->board.vbus_pin > 0 && !udc->board.vbus_polled && |
1951 | udc->active_suspend) | ||
1868 | disable_irq_wake(udc->board.vbus_pin); | 1952 | disable_irq_wake(udc->board.vbus_pin); |
1869 | 1953 | ||
1870 | /* maybe reconnect to host; if so, clocks on */ | 1954 | /* maybe reconnect to host; if so, clocks on */ |
1871 | if (udc->active_suspend) | 1955 | if (udc->active_suspend) |
1872 | disable_irq_wake(udc->udp_irq); | 1956 | disable_irq_wake(udc->udp_irq); |
1873 | else | 1957 | else { |
1958 | spin_lock_irqsave(&udc->lock, flags); | ||
1874 | pullup(udc, 1); | 1959 | pullup(udc, 1); |
1960 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1961 | } | ||
1875 | return 0; | 1962 | return 0; |
1876 | } | 1963 | } |
1877 | #else | 1964 | #else |
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h index c65d62295890..108ca54f9092 100644 --- a/drivers/usb/gadget/at91_udc.h +++ b/drivers/usb/gadget/at91_udc.h | |||
@@ -144,6 +144,9 @@ struct at91_udc { | |||
144 | struct proc_dir_entry *pde; | 144 | struct proc_dir_entry *pde; |
145 | void __iomem *udp_baseaddr; | 145 | void __iomem *udp_baseaddr; |
146 | int udp_irq; | 146 | int udp_irq; |
147 | spinlock_t lock; | ||
148 | struct timer_list vbus_timer; | ||
149 | struct work_struct vbus_timer_work; | ||
147 | }; | 150 | }; |
148 | 151 | ||
149 | static inline struct at91_udc *to_udc(struct usb_gadget *g) | 152 | static inline struct at91_udc *to_udc(struct usb_gadget *g) |
diff --git a/drivers/video/omap2/vram.c b/drivers/video/omap2/vram.c index 3b1237ad85ed..f6fdc2085f3e 100644 --- a/drivers/video/omap2/vram.c +++ b/drivers/video/omap2/vram.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/list.h> | 25 | #include <linux/list.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/seq_file.h> | 27 | #include <linux/seq_file.h> |
28 | #include <linux/bootmem.h> | 28 | #include <linux/memblock.h> |
29 | #include <linux/completion.h> | 29 | #include <linux/completion.h> |
30 | #include <linux/debugfs.h> | 30 | #include <linux/debugfs.h> |
31 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
@@ -525,10 +525,8 @@ early_param("vram", omap_vram_early_vram); | |||
525 | * Called from map_io. We need to call to this early enough so that we | 525 | * Called from map_io. We need to call to this early enough so that we |
526 | * can reserve the fixed SDRAM regions before VM could get hold of them. | 526 | * can reserve the fixed SDRAM regions before VM could get hold of them. |
527 | */ | 527 | */ |
528 | void __init omap_vram_reserve_sdram(void) | 528 | void __init omap_vram_reserve_sdram_memblock(void) |
529 | { | 529 | { |
530 | struct bootmem_data *bdata; | ||
531 | unsigned long sdram_start, sdram_size; | ||
532 | u32 paddr; | 530 | u32 paddr; |
533 | u32 size = 0; | 531 | u32 size = 0; |
534 | 532 | ||
@@ -555,29 +553,28 @@ void __init omap_vram_reserve_sdram(void) | |||
555 | 553 | ||
556 | size = PAGE_ALIGN(size); | 554 | size = PAGE_ALIGN(size); |
557 | 555 | ||
558 | bdata = NODE_DATA(0)->bdata; | ||
559 | sdram_start = bdata->node_min_pfn << PAGE_SHIFT; | ||
560 | sdram_size = (bdata->node_low_pfn << PAGE_SHIFT) - sdram_start; | ||
561 | |||
562 | if (paddr) { | 556 | if (paddr) { |
563 | if ((paddr & ~PAGE_MASK) || paddr < sdram_start || | 557 | struct memblock_property res; |
564 | paddr + size > sdram_start + sdram_size) { | 558 | |
559 | res.base = paddr; | ||
560 | res.size = size; | ||
561 | if ((paddr & ~PAGE_MASK) || memblock_find(&res) || | ||
562 | res.base != paddr || res.size != size) { | ||
565 | pr_err("Illegal SDRAM region for VRAM\n"); | 563 | pr_err("Illegal SDRAM region for VRAM\n"); |
566 | return; | 564 | return; |
567 | } | 565 | } |
568 | 566 | ||
569 | if (reserve_bootmem(paddr, size, BOOTMEM_EXCLUSIVE) < 0) { | 567 | if (memblock_is_region_reserved(paddr, size)) { |
570 | pr_err("FB: failed to reserve VRAM\n"); | 568 | pr_err("FB: failed to reserve VRAM - busy\n"); |
571 | return; | 569 | return; |
572 | } | 570 | } |
573 | } else { | 571 | |
574 | if (size > sdram_size) { | 572 | if (memblock_reserve(paddr, size) < 0) { |
575 | pr_err("Illegal SDRAM size for VRAM\n"); | 573 | pr_err("FB: failed to reserve VRAM - no memory\n"); |
576 | return; | 574 | return; |
577 | } | 575 | } |
578 | 576 | } else { | |
579 | paddr = virt_to_phys(alloc_bootmem_pages(size)); | 577 | paddr = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_REAL_LIMIT); |
580 | BUG_ON(paddr & ~PAGE_MASK); | ||
581 | } | 578 | } |
582 | 579 | ||
583 | omap_vram_add_region(paddr, size); | 580 | omap_vram_add_region(paddr, size); |