Blame view
arch/avr32/mach-at32ap/at32ap700x.c
53.9 KB
5f97f7f94 [PATCH] avr32 arc... |
1 2 3 4 5 6 7 8 |
/* * Copyright (C) 2005-2006 Atmel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <linux/clk.h> |
35bf50ccc avr32: Implement ... |
9 |
#include <linux/delay.h> |
3bfb1d20b dmaengine: Driver... |
10 |
#include <linux/dw_dmac.h> |
d0a2b7af2 [AVR32] Implement... |
11 |
#include <linux/fb.h> |
5f97f7f94 [PATCH] avr32 arc... |
12 13 |
#include <linux/init.h> #include <linux/platform_device.h> |
6b84bbfc7 [AVR32] Initializ... |
14 |
#include <linux/dma-mapping.h> |
5a0e3ad6a include cleanup: ... |
15 |
#include <linux/slab.h> |
3c26e1703 avr32: some mmc/s... |
16 |
#include <linux/gpio.h> |
41d8ca452 [AVR32] Use per-c... |
17 |
#include <linux/spi/spi.h> |
8d855317f atmel_usba_udc: m... |
18 |
#include <linux/usb/atmel_usba_udc.h> |
2635d1ba7 atmel-mci: change... |
19 20 |
#include <mach/atmel-mci.h> |
c42aa775c atmel-mci: move a... |
21 |
#include <linux/atmel-mci.h> |
5f97f7f94 [PATCH] avr32 arc... |
22 23 |
#include <asm/io.h> |
e7ba176b4 [AVR32] NMI debug... |
24 |
#include <asm/irq.h> |
5f97f7f94 [PATCH] avr32 arc... |
25 |
|
3663b736a avr32: Use <mach/... |
26 27 |
#include <mach/at32ap700x.h> #include <mach/board.h> |
b47eb4092 avr32: Clean up H... |
28 |
#include <mach/hmatrix.h> |
3663b736a avr32: Use <mach/... |
29 30 |
#include <mach/portmux.h> #include <mach/sram.h> |
5f97f7f94 [PATCH] avr32 arc... |
31 |
|
6b0c93514 avr32: at32ap700x... |
32 |
#include <sound/atmel-abdac.h> |
2f47c8c55 avr32: at32ap700x... |
33 |
#include <sound/atmel-ac97c.h> |
6b0c93514 avr32: at32ap700x... |
34 |
|
d0a2b7af2 [AVR32] Implement... |
35 |
#include <video/atmel_lcdc.h> |
5f97f7f94 [PATCH] avr32 arc... |
36 37 |
#include "clock.h" #include "pio.h" |
7a5b80590 [AVR32] Split SM ... |
38 |
#include "pm.h" |
5f97f7f94 [PATCH] avr32 arc... |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#define PBMEM(base) \ { \ .start = base, \ .end = base + 0x3ff, \ .flags = IORESOURCE_MEM, \ } #define IRQ(num) \ { \ .start = num, \ .end = num, \ .flags = IORESOURCE_IRQ, \ } #define NAMED_IRQ(num, _name) \ { \ .start = num, \ .end = num, \ .name = _name, \ .flags = IORESOURCE_IRQ, \ } |
6b84bbfc7 [AVR32] Initializ... |
59 60 61 |
/* REVISIT these assume *every* device supports DMA, but several * don't ... tc, smc, pio, rtc, watchdog, pwm, ps2, and more. */ |
5f97f7f94 [PATCH] avr32 arc... |
62 |
#define DEFINE_DEV(_name, _id) \ |
284901a90 dma-mapping: repl... |
63 |
static u64 _name##_id##_dma_mask = DMA_BIT_MASK(32); \ |
5f97f7f94 [PATCH] avr32 arc... |
64 65 66 |
static struct platform_device _name##_id##_device = { \ .name = #_name, \ .id = _id, \ |
6b84bbfc7 [AVR32] Initializ... |
67 68 |
.dev = { \ .dma_mask = &_name##_id##_dma_mask, \ |
284901a90 dma-mapping: repl... |
69 |
.coherent_dma_mask = DMA_BIT_MASK(32), \ |
6b84bbfc7 [AVR32] Initializ... |
70 |
}, \ |
5f97f7f94 [PATCH] avr32 arc... |
71 72 73 74 |
.resource = _name##_id##_resource, \ .num_resources = ARRAY_SIZE(_name##_id##_resource), \ } #define DEFINE_DEV_DATA(_name, _id) \ |
284901a90 dma-mapping: repl... |
75 |
static u64 _name##_id##_dma_mask = DMA_BIT_MASK(32); \ |
5f97f7f94 [PATCH] avr32 arc... |
76 77 78 79 |
static struct platform_device _name##_id##_device = { \ .name = #_name, \ .id = _id, \ .dev = { \ |
6b84bbfc7 [AVR32] Initializ... |
80 |
.dma_mask = &_name##_id##_dma_mask, \ |
5f97f7f94 [PATCH] avr32 arc... |
81 |
.platform_data = &_name##_id##_data, \ |
284901a90 dma-mapping: repl... |
82 |
.coherent_dma_mask = DMA_BIT_MASK(32), \ |
5f97f7f94 [PATCH] avr32 arc... |
83 84 85 86 |
}, \ .resource = _name##_id##_resource, \ .num_resources = ARRAY_SIZE(_name##_id##_resource), \ } |
caf18f19e avr32: Allow sele... |
87 88 89 |
#define select_peripheral(port, pin_mask, periph, flags) \ at32_select_periph(GPIO_##port##_BASE, pin_mask, \ GPIO_##periph, flags) |
c3e2a79c0 [AVR32] Portmux A... |
90 |
|
5f97f7f94 [PATCH] avr32 arc... |
91 92 93 94 95 96 97 98 99 |
#define DEV_CLK(_name, devname, bus, _index) \ static struct clk devname##_##_name = { \ .name = #_name, \ .dev = &devname##_device.dev, \ .parent = &bus##_clk, \ .mode = bus##_clk_mode, \ .get_rate = bus##_clk_get_rate, \ .index = _index, \ } |
7a5b80590 [AVR32] Split SM ... |
100 |
static DEFINE_SPINLOCK(pm_lock); |
35bf50ccc avr32: Implement ... |
101 102 |
static struct clk osc0; static struct clk osc1; |
5f97f7f94 [PATCH] avr32 arc... |
103 104 |
static unsigned long osc_get_rate(struct clk *clk) { |
60ed7951d avr32: Allow boar... |
105 |
return at32_board_osc_rates[clk->index]; |
5f97f7f94 [PATCH] avr32 arc... |
106 107 108 109 110 |
} static unsigned long pll_get_rate(struct clk *clk, unsigned long control) { unsigned long div, mul, rate; |
7a5b80590 [AVR32] Split SM ... |
111 112 |
div = PM_BFEXT(PLLDIV, control) + 1; mul = PM_BFEXT(PLLMUL, control) + 1; |
5f97f7f94 [PATCH] avr32 arc... |
113 114 115 116 117 118 119 |
rate = clk->parent->get_rate(clk->parent); rate = (rate + div / 2) / div; rate *= mul; return rate; } |
35bf50ccc avr32: Implement ... |
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
static long pll_set_rate(struct clk *clk, unsigned long rate, u32 *pll_ctrl) { unsigned long mul; unsigned long mul_best_fit = 0; unsigned long div; unsigned long div_min; unsigned long div_max; unsigned long div_best_fit = 0; unsigned long base; unsigned long pll_in; unsigned long actual = 0; unsigned long rate_error; unsigned long rate_error_prev = ~0UL; u32 ctrl; /* Rate must be between 80 MHz and 200 Mhz. */ if (rate < 80000000UL || rate > 200000000UL) return -EINVAL; ctrl = PM_BF(PLLOPT, 4); base = clk->parent->get_rate(clk->parent); /* PLL input frequency must be between 6 MHz and 32 MHz. */ div_min = DIV_ROUND_UP(base, 32000000UL); div_max = base / 6000000UL; if (div_max < div_min) return -EINVAL; for (div = div_min; div <= div_max; div++) { pll_in = (base + div / 2) / div; mul = (rate + pll_in / 2) / pll_in; if (mul == 0) continue; actual = pll_in * mul; rate_error = abs(actual - rate); if (rate_error < rate_error_prev) { mul_best_fit = mul; div_best_fit = div; rate_error_prev = rate_error; } if (rate_error == 0) break; } if (div_best_fit == 0) return -EINVAL; ctrl |= PM_BF(PLLMUL, mul_best_fit - 1); ctrl |= PM_BF(PLLDIV, div_best_fit - 1); ctrl |= PM_BF(PLLCOUNT, 16); if (clk->parent == &osc1) ctrl |= PM_BIT(PLLOSC); *pll_ctrl = ctrl; return actual; } |
5f97f7f94 [PATCH] avr32 arc... |
184 185 186 |
static unsigned long pll0_get_rate(struct clk *clk) { u32 control; |
7a5b80590 [AVR32] Split SM ... |
187 |
control = pm_readl(PLL0); |
5f97f7f94 [PATCH] avr32 arc... |
188 189 190 |
return pll_get_rate(clk, control); } |
35bf50ccc avr32: Implement ... |
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
static void pll1_mode(struct clk *clk, int enabled) { unsigned long timeout; u32 status; u32 ctrl; ctrl = pm_readl(PLL1); if (enabled) { if (!PM_BFEXT(PLLMUL, ctrl) && !PM_BFEXT(PLLDIV, ctrl)) { pr_debug("clk %s: failed to enable, rate not set ", clk->name); return; } ctrl |= PM_BIT(PLLEN); pm_writel(PLL1, ctrl); /* Wait for PLL lock. */ for (timeout = 10000; timeout; timeout--) { status = pm_readl(ISR); if (status & PM_BIT(LOCK1)) break; udelay(10); } if (!(status & PM_BIT(LOCK1))) printk(KERN_ERR "clk %s: timeout waiting for lock ", clk->name); } else { ctrl &= ~PM_BIT(PLLEN); pm_writel(PLL1, ctrl); } } |
5f97f7f94 [PATCH] avr32 arc... |
227 228 229 |
static unsigned long pll1_get_rate(struct clk *clk) { u32 control; |
7a5b80590 [AVR32] Split SM ... |
230 |
control = pm_readl(PLL1); |
5f97f7f94 [PATCH] avr32 arc... |
231 232 233 |
return pll_get_rate(clk, control); } |
35bf50ccc avr32: Implement ... |
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
static long pll1_set_rate(struct clk *clk, unsigned long rate, int apply) { u32 ctrl = 0; unsigned long actual_rate; actual_rate = pll_set_rate(clk, rate, &ctrl); if (apply) { if (actual_rate != rate) return -EINVAL; if (clk->users > 0) return -EBUSY; pr_debug(KERN_INFO "clk %s: new rate %lu (actual rate %lu) ", clk->name, rate, actual_rate); pm_writel(PLL1, ctrl); } return actual_rate; } static int pll1_set_parent(struct clk *clk, struct clk *parent) { u32 ctrl; if (clk->users > 0) return -EBUSY; ctrl = pm_readl(PLL1); WARN_ON(ctrl & PM_BIT(PLLEN)); if (parent == &osc0) ctrl &= ~PM_BIT(PLLOSC); else if (parent == &osc1) ctrl |= PM_BIT(PLLOSC); else return -EINVAL; pm_writel(PLL1, ctrl); clk->parent = parent; return 0; } |
5f97f7f94 [PATCH] avr32 arc... |
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
/* * The AT32AP7000 has five primary clock sources: One 32kHz * oscillator, two crystal oscillators and two PLLs. */ static struct clk osc32k = { .name = "osc32k", .get_rate = osc_get_rate, .users = 1, .index = 0, }; static struct clk osc0 = { .name = "osc0", .get_rate = osc_get_rate, .users = 1, .index = 1, }; static struct clk osc1 = { .name = "osc1", .get_rate = osc_get_rate, .index = 2, }; static struct clk pll0 = { .name = "pll0", .get_rate = pll0_get_rate, .parent = &osc0, }; static struct clk pll1 = { .name = "pll1", |
35bf50ccc avr32: Implement ... |
305 |
.mode = pll1_mode, |
5f97f7f94 [PATCH] avr32 arc... |
306 |
.get_rate = pll1_get_rate, |
35bf50ccc avr32: Implement ... |
307 308 |
.set_rate = pll1_set_rate, .set_parent = pll1_set_parent, |
5f97f7f94 [PATCH] avr32 arc... |
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
.parent = &osc0, }; /* * The main clock can be either osc0 or pll0. The boot loader may * have chosen one for us, so we don't really know which one until we * have a look at the SM. */ static struct clk *main_clock; /* * Synchronous clocks are generated from the main clock. The clocks * must satisfy the constraint * fCPU >= fHSB >= fPB * i.e. each clock must not be faster than its parent. */ static unsigned long bus_clk_get_rate(struct clk *clk, unsigned int shift) { return main_clock->get_rate(main_clock) >> shift; }; static void cpu_clk_mode(struct clk *clk, int enabled) { |
5f97f7f94 [PATCH] avr32 arc... |
332 333 |
unsigned long flags; u32 mask; |
7a5b80590 [AVR32] Split SM ... |
334 335 |
spin_lock_irqsave(&pm_lock, flags); mask = pm_readl(CPU_MASK); |
5f97f7f94 [PATCH] avr32 arc... |
336 337 338 339 |
if (enabled) mask |= 1 << clk->index; else mask &= ~(1 << clk->index); |
7a5b80590 [AVR32] Split SM ... |
340 341 |
pm_writel(CPU_MASK, mask); spin_unlock_irqrestore(&pm_lock, flags); |
5f97f7f94 [PATCH] avr32 arc... |
342 343 344 345 346 |
} static unsigned long cpu_clk_get_rate(struct clk *clk) { unsigned long cksel, shift = 0; |
7a5b80590 [AVR32] Split SM ... |
347 348 349 |
cksel = pm_readl(CKSEL); if (cksel & PM_BIT(CPUDIV)) shift = PM_BFEXT(CPUSEL, cksel) + 1; |
5f97f7f94 [PATCH] avr32 arc... |
350 351 352 |
return bus_clk_get_rate(clk, shift); } |
9e58e1855 [AVR32] CPU frequ... |
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
static long cpu_clk_set_rate(struct clk *clk, unsigned long rate, int apply) { u32 control; unsigned long parent_rate, child_div, actual_rate, div; parent_rate = clk->parent->get_rate(clk->parent); control = pm_readl(CKSEL); if (control & PM_BIT(HSBDIV)) child_div = 1 << (PM_BFEXT(HSBSEL, control) + 1); else child_div = 1; if (rate > 3 * (parent_rate / 4) || child_div == 1) { actual_rate = parent_rate; control &= ~PM_BIT(CPUDIV); } else { unsigned int cpusel; div = (parent_rate + rate / 2) / rate; if (div > child_div) div = child_div; cpusel = (div > 1) ? (fls(div) - 2) : 0; control = PM_BIT(CPUDIV) | PM_BFINS(CPUSEL, cpusel, control); actual_rate = parent_rate / (1 << (cpusel + 1)); } pr_debug("clk %s: new rate %lu (actual rate %lu) ", clk->name, rate, actual_rate); if (apply) pm_writel(CKSEL, control); return actual_rate; } |
5f97f7f94 [PATCH] avr32 arc... |
388 389 |
static void hsb_clk_mode(struct clk *clk, int enabled) { |
5f97f7f94 [PATCH] avr32 arc... |
390 391 |
unsigned long flags; u32 mask; |
7a5b80590 [AVR32] Split SM ... |
392 393 |
spin_lock_irqsave(&pm_lock, flags); mask = pm_readl(HSB_MASK); |
5f97f7f94 [PATCH] avr32 arc... |
394 395 396 397 |
if (enabled) mask |= 1 << clk->index; else mask &= ~(1 << clk->index); |
7a5b80590 [AVR32] Split SM ... |
398 399 |
pm_writel(HSB_MASK, mask); spin_unlock_irqrestore(&pm_lock, flags); |
5f97f7f94 [PATCH] avr32 arc... |
400 401 402 403 404 |
} static unsigned long hsb_clk_get_rate(struct clk *clk) { unsigned long cksel, shift = 0; |
7a5b80590 [AVR32] Split SM ... |
405 406 407 |
cksel = pm_readl(CKSEL); if (cksel & PM_BIT(HSBDIV)) shift = PM_BFEXT(HSBSEL, cksel) + 1; |
5f97f7f94 [PATCH] avr32 arc... |
408 409 410 |
return bus_clk_get_rate(clk, shift); } |
dd5e1339e avr32: Hammerhead... |
411 |
void pba_clk_mode(struct clk *clk, int enabled) |
5f97f7f94 [PATCH] avr32 arc... |
412 |
{ |
5f97f7f94 [PATCH] avr32 arc... |
413 414 |
unsigned long flags; u32 mask; |
7a5b80590 [AVR32] Split SM ... |
415 416 |
spin_lock_irqsave(&pm_lock, flags); mask = pm_readl(PBA_MASK); |
5f97f7f94 [PATCH] avr32 arc... |
417 418 419 420 |
if (enabled) mask |= 1 << clk->index; else mask &= ~(1 << clk->index); |
7a5b80590 [AVR32] Split SM ... |
421 422 |
pm_writel(PBA_MASK, mask); spin_unlock_irqrestore(&pm_lock, flags); |
5f97f7f94 [PATCH] avr32 arc... |
423 |
} |
dd5e1339e avr32: Hammerhead... |
424 |
unsigned long pba_clk_get_rate(struct clk *clk) |
5f97f7f94 [PATCH] avr32 arc... |
425 426 |
{ unsigned long cksel, shift = 0; |
7a5b80590 [AVR32] Split SM ... |
427 428 429 |
cksel = pm_readl(CKSEL); if (cksel & PM_BIT(PBADIV)) shift = PM_BFEXT(PBASEL, cksel) + 1; |
5f97f7f94 [PATCH] avr32 arc... |
430 431 432 433 434 435 |
return bus_clk_get_rate(clk, shift); } static void pbb_clk_mode(struct clk *clk, int enabled) { |
5f97f7f94 [PATCH] avr32 arc... |
436 437 |
unsigned long flags; u32 mask; |
7a5b80590 [AVR32] Split SM ... |
438 439 |
spin_lock_irqsave(&pm_lock, flags); mask = pm_readl(PBB_MASK); |
5f97f7f94 [PATCH] avr32 arc... |
440 441 442 443 |
if (enabled) mask |= 1 << clk->index; else mask &= ~(1 << clk->index); |
7a5b80590 [AVR32] Split SM ... |
444 445 |
pm_writel(PBB_MASK, mask); spin_unlock_irqrestore(&pm_lock, flags); |
5f97f7f94 [PATCH] avr32 arc... |
446 447 448 449 450 |
} static unsigned long pbb_clk_get_rate(struct clk *clk) { unsigned long cksel, shift = 0; |
7a5b80590 [AVR32] Split SM ... |
451 452 453 |
cksel = pm_readl(CKSEL); if (cksel & PM_BIT(PBBDIV)) shift = PM_BFEXT(PBBSEL, cksel) + 1; |
5f97f7f94 [PATCH] avr32 arc... |
454 455 456 457 458 459 460 |
return bus_clk_get_rate(clk, shift); } static struct clk cpu_clk = { .name = "cpu", .get_rate = cpu_clk_get_rate, |
9e58e1855 [AVR32] CPU frequ... |
461 |
.set_rate = cpu_clk_set_rate, |
5f97f7f94 [PATCH] avr32 arc... |
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
.users = 1, }; static struct clk hsb_clk = { .name = "hsb", .parent = &cpu_clk, .get_rate = hsb_clk_get_rate, }; static struct clk pba_clk = { .name = "pba", .parent = &hsb_clk, .mode = hsb_clk_mode, .get_rate = pba_clk_get_rate, .index = 1, }; static struct clk pbb_clk = { .name = "pbb", .parent = &hsb_clk, .mode = hsb_clk_mode, .get_rate = pbb_clk_get_rate, .users = 1, .index = 2, }; /* -------------------------------------------------------------------- * Generic Clock operations * -------------------------------------------------------------------- */ static void genclk_mode(struct clk *clk, int enabled) { u32 control; |
7a5b80590 [AVR32] Split SM ... |
492 |
control = pm_readl(GCCTRL(clk->index)); |
5f97f7f94 [PATCH] avr32 arc... |
493 |
if (enabled) |
7a5b80590 [AVR32] Split SM ... |
494 |
control |= PM_BIT(CEN); |
5f97f7f94 [PATCH] avr32 arc... |
495 |
else |
7a5b80590 [AVR32] Split SM ... |
496 497 |
control &= ~PM_BIT(CEN); pm_writel(GCCTRL(clk->index), control); |
5f97f7f94 [PATCH] avr32 arc... |
498 499 500 501 502 503 |
} static unsigned long genclk_get_rate(struct clk *clk) { u32 control; unsigned long div = 1; |
7a5b80590 [AVR32] Split SM ... |
504 505 506 |
control = pm_readl(GCCTRL(clk->index)); if (control & PM_BIT(DIVEN)) div = 2 * (PM_BFEXT(DIV, control) + 1); |
5f97f7f94 [PATCH] avr32 arc... |
507 508 509 510 511 512 513 514 |
return clk->parent->get_rate(clk->parent) / div; } static long genclk_set_rate(struct clk *clk, unsigned long rate, int apply) { u32 control; unsigned long parent_rate, actual_rate, div; |
5f97f7f94 [PATCH] avr32 arc... |
515 |
parent_rate = clk->parent->get_rate(clk->parent); |
7a5b80590 [AVR32] Split SM ... |
516 |
control = pm_readl(GCCTRL(clk->index)); |
5f97f7f94 [PATCH] avr32 arc... |
517 518 519 |
if (rate > 3 * parent_rate / 4) { actual_rate = parent_rate; |
7a5b80590 [AVR32] Split SM ... |
520 |
control &= ~PM_BIT(DIVEN); |
5f97f7f94 [PATCH] avr32 arc... |
521 522 |
} else { div = (parent_rate + rate) / (2 * rate) - 1; |
7a5b80590 [AVR32] Split SM ... |
523 |
control = PM_BFINS(DIV, div, control) | PM_BIT(DIVEN); |
5f97f7f94 [PATCH] avr32 arc... |
524 525 |
actual_rate = parent_rate / (2 * (div + 1)); } |
7a5b80590 [AVR32] Split SM ... |
526 527 528 |
dev_dbg(clk->dev, "clk %s: new rate %lu (actual rate %lu) ", clk->name, rate, actual_rate); |
5f97f7f94 [PATCH] avr32 arc... |
529 530 |
if (apply) |
7a5b80590 [AVR32] Split SM ... |
531 |
pm_writel(GCCTRL(clk->index), control); |
5f97f7f94 [PATCH] avr32 arc... |
532 533 534 535 536 537 538 |
return actual_rate; } int genclk_set_parent(struct clk *clk, struct clk *parent) { u32 control; |
7a5b80590 [AVR32] Split SM ... |
539 540 541 |
dev_dbg(clk->dev, "clk %s: new parent %s (was %s) ", clk->name, parent->name, clk->parent->name); |
5f97f7f94 [PATCH] avr32 arc... |
542 |
|
7a5b80590 [AVR32] Split SM ... |
543 |
control = pm_readl(GCCTRL(clk->index)); |
5f97f7f94 [PATCH] avr32 arc... |
544 545 |
if (parent == &osc1 || parent == &pll1) |
7a5b80590 [AVR32] Split SM ... |
546 |
control |= PM_BIT(OSCSEL); |
5f97f7f94 [PATCH] avr32 arc... |
547 |
else if (parent == &osc0 || parent == &pll0) |
7a5b80590 [AVR32] Split SM ... |
548 |
control &= ~PM_BIT(OSCSEL); |
5f97f7f94 [PATCH] avr32 arc... |
549 550 551 552 |
else return -EINVAL; if (parent == &pll0 || parent == &pll1) |
7a5b80590 [AVR32] Split SM ... |
553 |
control |= PM_BIT(PLLSEL); |
5f97f7f94 [PATCH] avr32 arc... |
554 |
else |
7a5b80590 [AVR32] Split SM ... |
555 |
control &= ~PM_BIT(PLLSEL); |
5f97f7f94 [PATCH] avr32 arc... |
556 |
|
7a5b80590 [AVR32] Split SM ... |
557 |
pm_writel(GCCTRL(clk->index), control); |
5f97f7f94 [PATCH] avr32 arc... |
558 559 560 561 |
clk->parent = parent; return 0; } |
7a5fe2387 [AVR32] Make sure... |
562 563 564 565 566 567 |
static void __init genclk_init_parent(struct clk *clk) { u32 control; struct clk *parent; BUG_ON(clk->index > 7); |
7a5b80590 [AVR32] Split SM ... |
568 569 570 |
control = pm_readl(GCCTRL(clk->index)); if (control & PM_BIT(OSCSEL)) parent = (control & PM_BIT(PLLSEL)) ? &pll1 : &osc1; |
7a5fe2387 [AVR32] Make sure... |
571 |
else |
7a5b80590 [AVR32] Split SM ... |
572 |
parent = (control & PM_BIT(PLLSEL)) ? &pll0 : &osc0; |
7a5fe2387 [AVR32] Make sure... |
573 574 575 |
clk->parent = parent; } |
3bfb1d20b dmaengine: Driver... |
576 577 578 579 580 581 582 583 584 585 |
static struct dw_dma_platform_data dw_dmac0_data = { .nr_channels = 3, }; static struct resource dw_dmac0_resource[] = { PBMEM(0xff200000), IRQ(2), }; DEFINE_DEV_DATA(dw_dmac, 0); DEV_CLK(hclk, dw_dmac0, hsb, 10); |
5f97f7f94 [PATCH] avr32 arc... |
586 587 588 |
/* -------------------------------------------------------------------- * System peripherals * -------------------------------------------------------------------- */ |
7a5b80590 [AVR32] Split SM ... |
589 590 591 592 593 594 595 |
static struct resource at32_pm0_resource[] = { { .start = 0xfff00000, .end = 0xfff0007f, .flags = IORESOURCE_MEM, }, IRQ(20), |
5f97f7f94 [PATCH] avr32 arc... |
596 |
}; |
7a5b80590 [AVR32] Split SM ... |
597 598 599 600 601 602 603 604 |
static struct resource at32ap700x_rtc0_resource[] = { { .start = 0xfff00080, .end = 0xfff000af, .flags = IORESOURCE_MEM, }, IRQ(21), |
5f97f7f94 [PATCH] avr32 arc... |
605 |
}; |
7a5b80590 [AVR32] Split SM ... |
606 607 608 609 |
static struct resource at32_wdt0_resource[] = { { .start = 0xfff000b0, |
9797bed20 Extend I/O resour... |
610 |
.end = 0xfff000cf, |
7a5b80590 [AVR32] Split SM ... |
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
.flags = IORESOURCE_MEM, }, }; static struct resource at32_eic0_resource[] = { { .start = 0xfff00100, .end = 0xfff0013f, .flags = IORESOURCE_MEM, }, IRQ(19), }; DEFINE_DEV(at32_pm, 0); DEFINE_DEV(at32ap700x_rtc, 0); DEFINE_DEV(at32_wdt, 0); DEFINE_DEV(at32_eic, 0); /* * Peripheral clock for PM, RTC, WDT and EIC. PM will ensure that this * is always running. */ static struct clk at32_pm_pclk = { |
188ff65d4 [AVR32] Don't ena... |
634 |
.name = "pclk", |
7a5b80590 [AVR32] Split SM ... |
635 |
.dev = &at32_pm0_device.dev, |
188ff65d4 [AVR32] Don't ena... |
636 637 638 639 640 641 |
.parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .users = 1, .index = 0, }; |
5f97f7f94 [PATCH] avr32 arc... |
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
static struct resource intc0_resource[] = { PBMEM(0xfff00400), }; struct platform_device at32_intc0_device = { .name = "intc", .id = 0, .resource = intc0_resource, .num_resources = ARRAY_SIZE(intc0_resource), }; DEV_CLK(pclk, at32_intc0, pbb, 1); static struct clk ebi_clk = { .name = "ebi", .parent = &hsb_clk, .mode = hsb_clk_mode, .get_rate = hsb_clk_get_rate, .users = 1, }; static struct clk hramc_clk = { .name = "hramc", .parent = &hsb_clk, .mode = hsb_clk_mode, .get_rate = hsb_clk_get_rate, .users = 1, |
188ff65d4 [AVR32] Don't ena... |
667 |
.index = 3, |
5f97f7f94 [PATCH] avr32 arc... |
668 |
}; |
7951f188a avr32: Enable SDR... |
669 670 671 672 673 674 675 676 |
static struct clk sdramc_clk = { .name = "sdramc_clk", .parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .users = 1, .index = 14, }; |
5f97f7f94 [PATCH] avr32 arc... |
677 |
|
bc157b759 [PATCH] AVR32 MTD... |
678 679 680 681 682 683 |
static struct resource smc0_resource[] = { PBMEM(0xfff03400), }; DEFINE_DEV(smc, 0); DEV_CLK(pclk, smc0, pbb, 13); DEV_CLK(mck, smc0, hsb, 0); |
5f97f7f94 [PATCH] avr32 arc... |
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
static struct platform_device pdc_device = { .name = "pdc", .id = 0, }; DEV_CLK(hclk, pdc, hsb, 4); DEV_CLK(pclk, pdc, pba, 16); static struct clk pico_clk = { .name = "pico", .parent = &cpu_clk, .mode = cpu_clk_mode, .get_rate = cpu_clk_get_rate, .users = 1, }; /* -------------------------------------------------------------------- |
9c8f8e752 [AVR32] Add basic... |
700 701 |
* HMATRIX * -------------------------------------------------------------------- */ |
b47eb4092 avr32: Clean up H... |
702 |
struct clk at32_hmatrix_clk = { |
9c8f8e752 [AVR32] Add basic... |
703 704 705 706 707 708 709 |
.name = "hmatrix_clk", .parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .index = 2, .users = 1, }; |
9c8f8e752 [AVR32] Add basic... |
710 711 712 713 714 715 716 717 718 |
/* * Set bits in the HMATRIX Special Function Register (SFR) used by the * External Bus Interface (EBI). This can be used to enable special * features like CompactFlash support, NAND Flash support, etc. on * certain chipselects. */ static inline void set_ebi_sfr_bits(u32 mask) { |
b47eb4092 avr32: Clean up H... |
719 |
hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, mask); |
9c8f8e752 [AVR32] Add basic... |
720 721 722 |
} /* -------------------------------------------------------------------- |
e723ff666 avr32: Generic cl... |
723 |
* Timer/Counter (TC) |
7760989e5 [AVR32] Change sy... |
724 |
* -------------------------------------------------------------------- */ |
e723ff666 avr32: Generic cl... |
725 726 |
static struct resource at32_tcb0_resource[] = { |
7760989e5 [AVR32] Change sy... |
727 728 729 |
PBMEM(0xfff00c00), IRQ(22), }; |
e723ff666 avr32: Generic cl... |
730 731 |
static struct platform_device at32_tcb0_device = { .name = "atmel_tcb", |
7760989e5 [AVR32] Change sy... |
732 |
.id = 0, |
e723ff666 avr32: Generic cl... |
733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
.resource = at32_tcb0_resource, .num_resources = ARRAY_SIZE(at32_tcb0_resource), }; DEV_CLK(t0_clk, at32_tcb0, pbb, 3); static struct resource at32_tcb1_resource[] = { PBMEM(0xfff01000), IRQ(23), }; static struct platform_device at32_tcb1_device = { .name = "atmel_tcb", .id = 1, .resource = at32_tcb1_resource, .num_resources = ARRAY_SIZE(at32_tcb1_resource), |
7760989e5 [AVR32] Change sy... |
747 |
}; |
e723ff666 avr32: Generic cl... |
748 |
DEV_CLK(t0_clk, at32_tcb1, pbb, 4); |
7760989e5 [AVR32] Change sy... |
749 750 |
/* -------------------------------------------------------------------- |
5f97f7f94 [PATCH] avr32 arc... |
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
* PIO * -------------------------------------------------------------------- */ static struct resource pio0_resource[] = { PBMEM(0xffe02800), IRQ(13), }; DEFINE_DEV(pio, 0); DEV_CLK(mck, pio0, pba, 10); static struct resource pio1_resource[] = { PBMEM(0xffe02c00), IRQ(14), }; DEFINE_DEV(pio, 1); DEV_CLK(mck, pio1, pba, 11); static struct resource pio2_resource[] = { PBMEM(0xffe03000), IRQ(15), }; DEFINE_DEV(pio, 2); DEV_CLK(mck, pio2, pba, 12); static struct resource pio3_resource[] = { PBMEM(0xffe03400), IRQ(16), }; DEFINE_DEV(pio, 3); DEV_CLK(mck, pio3, pba, 13); |
7f9f46786 [AVR32] Add PIOE ... |
781 782 783 784 785 786 |
static struct resource pio4_resource[] = { PBMEM(0xffe03800), IRQ(17), }; DEFINE_DEV(pio, 4); DEV_CLK(mck, pio4, pba, 14); |
e82c6106b avr32: Fix GPIO i... |
787 |
static int __init system_device_init(void) |
5f97f7f94 [PATCH] avr32 arc... |
788 |
{ |
7a5b80590 [AVR32] Split SM ... |
789 |
platform_device_register(&at32_pm0_device); |
5f97f7f94 [PATCH] avr32 arc... |
790 |
platform_device_register(&at32_intc0_device); |
7a5b80590 [AVR32] Split SM ... |
791 792 793 |
platform_device_register(&at32ap700x_rtc0_device); platform_device_register(&at32_wdt0_device); platform_device_register(&at32_eic0_device); |
bc157b759 [PATCH] AVR32 MTD... |
794 |
platform_device_register(&smc0_device); |
5f97f7f94 [PATCH] avr32 arc... |
795 |
platform_device_register(&pdc_device); |
3bfb1d20b dmaengine: Driver... |
796 |
platform_device_register(&dw_dmac0_device); |
5f97f7f94 [PATCH] avr32 arc... |
797 |
|
e723ff666 avr32: Generic cl... |
798 799 |
platform_device_register(&at32_tcb0_device); platform_device_register(&at32_tcb1_device); |
7760989e5 [AVR32] Change sy... |
800 |
|
5f97f7f94 [PATCH] avr32 arc... |
801 802 803 804 |
platform_device_register(&pio0_device); platform_device_register(&pio1_device); platform_device_register(&pio2_device); platform_device_register(&pio3_device); |
7f9f46786 [AVR32] Add PIOE ... |
805 |
platform_device_register(&pio4_device); |
e82c6106b avr32: Fix GPIO i... |
806 807 |
return 0; |
5f97f7f94 [PATCH] avr32 arc... |
808 |
} |
e82c6106b avr32: Fix GPIO i... |
809 |
core_initcall(system_device_init); |
5f97f7f94 [PATCH] avr32 arc... |
810 811 |
/* -------------------------------------------------------------------- |
d86d314f6 avr32: Add PSIF p... |
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
* PSIF * -------------------------------------------------------------------- */ static struct resource atmel_psif0_resource[] __initdata = { { .start = 0xffe03c00, .end = 0xffe03cff, .flags = IORESOURCE_MEM, }, IRQ(18), }; static struct clk atmel_psif0_pclk = { .name = "pclk", .parent = &pba_clk, .mode = pba_clk_mode, .get_rate = pba_clk_get_rate, .index = 15, }; static struct resource atmel_psif1_resource[] __initdata = { { .start = 0xffe03d00, .end = 0xffe03dff, .flags = IORESOURCE_MEM, }, IRQ(18), }; static struct clk atmel_psif1_pclk = { .name = "pclk", .parent = &pba_clk, .mode = pba_clk_mode, .get_rate = pba_clk_get_rate, .index = 15, }; struct platform_device *__init at32_add_device_psif(unsigned int id) { struct platform_device *pdev; |
caf18f19e avr32: Allow sele... |
849 |
u32 pin_mask; |
d86d314f6 avr32: Add PSIF p... |
850 851 852 853 854 855 856 857 858 859 |
if (!(id == 0 || id == 1)) return NULL; pdev = platform_device_alloc("atmel_psif", id); if (!pdev) return NULL; switch (id) { case 0: |
caf18f19e avr32: Allow sele... |
860 |
pin_mask = (1 << 8) | (1 << 9); /* CLOCK & DATA */ |
d86d314f6 avr32: Add PSIF p... |
861 862 863 864 |
if (platform_device_add_resources(pdev, atmel_psif0_resource, ARRAY_SIZE(atmel_psif0_resource))) goto err_add_resources; atmel_psif0_pclk.dev = &pdev->dev; |
caf18f19e avr32: Allow sele... |
865 |
select_peripheral(PIOA, pin_mask, PERIPH_A, 0); |
d86d314f6 avr32: Add PSIF p... |
866 867 |
break; case 1: |
caf18f19e avr32: Allow sele... |
868 |
pin_mask = (1 << 11) | (1 << 12); /* CLOCK & DATA */ |
d86d314f6 avr32: Add PSIF p... |
869 870 871 872 |
if (platform_device_add_resources(pdev, atmel_psif1_resource, ARRAY_SIZE(atmel_psif1_resource))) goto err_add_resources; atmel_psif1_pclk.dev = &pdev->dev; |
caf18f19e avr32: Allow sele... |
873 |
select_peripheral(PIOB, pin_mask, PERIPH_A, 0); |
d86d314f6 avr32: Add PSIF p... |
874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
break; default: return NULL; } platform_device_add(pdev); return pdev; err_add_resources: platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- |
5f97f7f94 [PATCH] avr32 arc... |
888 889 |
* USART * -------------------------------------------------------------------- */ |
75d352137 [PATCH] atmel_ser... |
890 891 892 893 |
static struct atmel_uart_data atmel_usart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, }; |
1e8ea8021 [PATCH] at91_seri... |
894 |
static struct resource atmel_usart0_resource[] = { |
5f97f7f94 [PATCH] avr32 arc... |
895 |
PBMEM(0xffe00c00), |
a3d912c8f [AVR32] fix seria... |
896 |
IRQ(6), |
5f97f7f94 [PATCH] avr32 arc... |
897 |
}; |
75d352137 [PATCH] atmel_ser... |
898 |
DEFINE_DEV_DATA(atmel_usart, 0); |
80f76c54b [AVR32] Fix dupli... |
899 |
DEV_CLK(usart, atmel_usart0, pba, 3); |
5f97f7f94 [PATCH] avr32 arc... |
900 |
|
75d352137 [PATCH] atmel_ser... |
901 902 903 904 |
static struct atmel_uart_data atmel_usart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, }; |
1e8ea8021 [PATCH] at91_seri... |
905 |
static struct resource atmel_usart1_resource[] = { |
5f97f7f94 [PATCH] avr32 arc... |
906 907 908 |
PBMEM(0xffe01000), IRQ(7), }; |
75d352137 [PATCH] atmel_ser... |
909 |
DEFINE_DEV_DATA(atmel_usart, 1); |
1e8ea8021 [PATCH] at91_seri... |
910 |
DEV_CLK(usart, atmel_usart1, pba, 4); |
5f97f7f94 [PATCH] avr32 arc... |
911 |
|
75d352137 [PATCH] atmel_ser... |
912 913 914 915 |
static struct atmel_uart_data atmel_usart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, }; |
1e8ea8021 [PATCH] at91_seri... |
916 |
static struct resource atmel_usart2_resource[] = { |
5f97f7f94 [PATCH] avr32 arc... |
917 918 919 |
PBMEM(0xffe01400), IRQ(8), }; |
75d352137 [PATCH] atmel_ser... |
920 |
DEFINE_DEV_DATA(atmel_usart, 2); |
1e8ea8021 [PATCH] at91_seri... |
921 |
DEV_CLK(usart, atmel_usart2, pba, 5); |
5f97f7f94 [PATCH] avr32 arc... |
922 |
|
75d352137 [PATCH] atmel_ser... |
923 924 925 926 |
static struct atmel_uart_data atmel_usart3_data = { .use_dma_tx = 1, .use_dma_rx = 1, }; |
1e8ea8021 [PATCH] at91_seri... |
927 |
static struct resource atmel_usart3_resource[] = { |
5f97f7f94 [PATCH] avr32 arc... |
928 929 930 |
PBMEM(0xffe01800), IRQ(9), }; |
75d352137 [PATCH] atmel_ser... |
931 |
DEFINE_DEV_DATA(atmel_usart, 3); |
1e8ea8021 [PATCH] at91_seri... |
932 |
DEV_CLK(usart, atmel_usart3, pba, 6); |
5f97f7f94 [PATCH] avr32 arc... |
933 |
|
bf4861cf3 avr32: add RTS/CT... |
934 |
static inline void configure_usart0_pins(int flags) |
5f97f7f94 [PATCH] avr32 arc... |
935 |
{ |
caf18f19e avr32: Allow sele... |
936 |
u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */ |
bf4861cf3 avr32: add RTS/CT... |
937 938 939 |
if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 6); if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 7); if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 10); |
caf18f19e avr32: Allow sele... |
940 |
|
105462632 avr32: Enable pul... |
941 |
select_peripheral(PIOA, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); |
5f97f7f94 [PATCH] avr32 arc... |
942 |
} |
bf4861cf3 avr32: add RTS/CT... |
943 |
static inline void configure_usart1_pins(int flags) |
5f97f7f94 [PATCH] avr32 arc... |
944 |
{ |
caf18f19e avr32: Allow sele... |
945 |
u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */ |
bf4861cf3 avr32: add RTS/CT... |
946 947 948 |
if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 19); if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 20); if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 16); |
caf18f19e avr32: Allow sele... |
949 |
|
105462632 avr32: Enable pul... |
950 |
select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP); |
5f97f7f94 [PATCH] avr32 arc... |
951 |
} |
bf4861cf3 avr32: add RTS/CT... |
952 |
static inline void configure_usart2_pins(int flags) |
5f97f7f94 [PATCH] avr32 arc... |
953 |
{ |
caf18f19e avr32: Allow sele... |
954 |
u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */ |
bf4861cf3 avr32: add RTS/CT... |
955 956 957 |
if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 30); if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 29); if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 28); |
caf18f19e avr32: Allow sele... |
958 |
|
105462632 avr32: Enable pul... |
959 |
select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); |
5f97f7f94 [PATCH] avr32 arc... |
960 |
} |
bf4861cf3 avr32: add RTS/CT... |
961 |
static inline void configure_usart3_pins(int flags) |
5f97f7f94 [PATCH] avr32 arc... |
962 |
{ |
caf18f19e avr32: Allow sele... |
963 |
u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */ |
bf4861cf3 avr32: add RTS/CT... |
964 965 966 |
if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 16); if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 15); if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 19); |
caf18f19e avr32: Allow sele... |
967 |
|
105462632 avr32: Enable pul... |
968 |
select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP); |
5f97f7f94 [PATCH] avr32 arc... |
969 |
} |
a3d912c8f [AVR32] fix seria... |
970 |
static struct platform_device *__initdata at32_usarts[4]; |
c194588db [PATCH] AVR32: Al... |
971 |
|
bf4861cf3 avr32: add RTS/CT... |
972 |
void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags) |
5f97f7f94 [PATCH] avr32 arc... |
973 974 |
{ struct platform_device *pdev; |
2b348e2f8 atmel_serial: kee... |
975 |
struct atmel_uart_data *pdata; |
5f97f7f94 [PATCH] avr32 arc... |
976 |
|
c194588db [PATCH] AVR32: Al... |
977 |
switch (hw_id) { |
5f97f7f94 [PATCH] avr32 arc... |
978 |
case 0: |
1e8ea8021 [PATCH] at91_seri... |
979 |
pdev = &atmel_usart0_device; |
bf4861cf3 avr32: add RTS/CT... |
980 |
configure_usart0_pins(flags); |
5f97f7f94 [PATCH] avr32 arc... |
981 982 |
break; case 1: |
1e8ea8021 [PATCH] at91_seri... |
983 |
pdev = &atmel_usart1_device; |
bf4861cf3 avr32: add RTS/CT... |
984 |
configure_usart1_pins(flags); |
5f97f7f94 [PATCH] avr32 arc... |
985 986 |
break; case 2: |
1e8ea8021 [PATCH] at91_seri... |
987 |
pdev = &atmel_usart2_device; |
bf4861cf3 avr32: add RTS/CT... |
988 |
configure_usart2_pins(flags); |
5f97f7f94 [PATCH] avr32 arc... |
989 990 |
break; case 3: |
1e8ea8021 [PATCH] at91_seri... |
991 |
pdev = &atmel_usart3_device; |
bf4861cf3 avr32: add RTS/CT... |
992 |
configure_usart3_pins(flags); |
5f97f7f94 [PATCH] avr32 arc... |
993 994 |
break; default: |
c194588db [PATCH] AVR32: Al... |
995 |
return; |
75d352137 [PATCH] atmel_ser... |
996 997 998 999 1000 1001 |
} if (PXSEG(pdev->resource[0].start) == P4SEG) { /* Addresses in the P4 segment are permanently mapped 1:1 */ struct atmel_uart_data *data = pdev->dev.platform_data; data->regs = (void __iomem *)pdev->resource[0].start; |
5f97f7f94 [PATCH] avr32 arc... |
1002 |
} |
4137b3156 avr32/at32ap: fix... |
1003 |
pdev->id = line; |
2b348e2f8 atmel_serial: kee... |
1004 |
pdata = pdev->dev.platform_data; |
7bbf1d46b avr32: fix use of... |
1005 |
pdata->num = line; |
c194588db [PATCH] AVR32: Al... |
1006 |
at32_usarts[line] = pdev; |
5f97f7f94 [PATCH] avr32 arc... |
1007 1008 1009 1010 |
} struct platform_device *__init at32_add_device_usart(unsigned int id) { |
c194588db [PATCH] AVR32: Al... |
1011 1012 |
platform_device_register(at32_usarts[id]); return at32_usarts[id]; |
5f97f7f94 [PATCH] avr32 arc... |
1013 |
} |
73e2798b0 [PATCH] at91_seri... |
1014 |
struct platform_device *atmel_default_console_device; |
5f97f7f94 [PATCH] avr32 arc... |
1015 1016 1017 |
void __init at32_setup_serial_console(unsigned int usart_id) { |
c194588db [PATCH] AVR32: Al... |
1018 |
atmel_default_console_device = at32_usarts[usart_id]; |
5f97f7f94 [PATCH] avr32 arc... |
1019 1020 1021 1022 1023 |
} /* -------------------------------------------------------------------- * Ethernet * -------------------------------------------------------------------- */ |
438ff3f3c [AVR32] Add suppo... |
1024 |
#ifdef CONFIG_CPU_AT32AP7000 |
84e0cdb0a macb: unify at91 ... |
1025 |
static struct macb_platform_data macb0_data; |
5f97f7f94 [PATCH] avr32 arc... |
1026 1027 1028 1029 1030 1031 1032 |
static struct resource macb0_resource[] = { PBMEM(0xfff01800), IRQ(25), }; DEFINE_DEV_DATA(macb, 0); DEV_CLK(hclk, macb0, hsb, 8); DEV_CLK(pclk, macb0, pbb, 6); |
84e0cdb0a macb: unify at91 ... |
1033 |
static struct macb_platform_data macb1_data; |
cfcb3a89d [AVR32] Add macb1... |
1034 1035 1036 1037 1038 1039 1040 |
static struct resource macb1_resource[] = { PBMEM(0xfff01c00), IRQ(26), }; DEFINE_DEV_DATA(macb, 1); DEV_CLK(hclk, macb1, hsb, 9); DEV_CLK(pclk, macb1, pbb, 7); |
5f97f7f94 [PATCH] avr32 arc... |
1041 |
struct platform_device *__init |
84e0cdb0a macb: unify at91 ... |
1042 |
at32_add_device_eth(unsigned int id, struct macb_platform_data *data) |
5f97f7f94 [PATCH] avr32 arc... |
1043 1044 |
{ struct platform_device *pdev; |
caf18f19e avr32: Allow sele... |
1045 |
u32 pin_mask; |
5f97f7f94 [PATCH] avr32 arc... |
1046 1047 1048 1049 |
switch (id) { case 0: pdev = &macb0_device; |
caf18f19e avr32: Allow sele... |
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
pin_mask = (1 << 3); /* TXD0 */ pin_mask |= (1 << 4); /* TXD1 */ pin_mask |= (1 << 7); /* TXEN */ pin_mask |= (1 << 8); /* TXCK */ pin_mask |= (1 << 9); /* RXD0 */ pin_mask |= (1 << 10); /* RXD1 */ pin_mask |= (1 << 13); /* RXER */ pin_mask |= (1 << 15); /* RXDV */ pin_mask |= (1 << 16); /* MDC */ pin_mask |= (1 << 17); /* MDIO */ |
5f97f7f94 [PATCH] avr32 arc... |
1060 1061 |
if (!data->is_rmii) { |
caf18f19e avr32: Allow sele... |
1062 1063 1064 1065 1066 1067 1068 1069 |
pin_mask |= (1 << 0); /* COL */ pin_mask |= (1 << 1); /* CRS */ pin_mask |= (1 << 2); /* TXER */ pin_mask |= (1 << 5); /* TXD2 */ pin_mask |= (1 << 6); /* TXD3 */ pin_mask |= (1 << 11); /* RXD2 */ pin_mask |= (1 << 12); /* RXD3 */ pin_mask |= (1 << 14); /* RXCK */ |
198f29358 avr32: Fix MIMC20... |
1070 |
#ifndef CONFIG_BOARD_MIMC200 |
caf18f19e avr32: Allow sele... |
1071 |
pin_mask |= (1 << 18); /* SPD */ |
198f29358 avr32: Fix MIMC20... |
1072 |
#endif |
5f97f7f94 [PATCH] avr32 arc... |
1073 |
} |
caf18f19e avr32: Allow sele... |
1074 1075 |
select_peripheral(PIOC, pin_mask, PERIPH_A, 0); |
5f97f7f94 [PATCH] avr32 arc... |
1076 |
break; |
cfcb3a89d [AVR32] Add macb1... |
1077 1078 |
case 1: pdev = &macb1_device; |
caf18f19e avr32: Allow sele... |
1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 |
pin_mask = (1 << 13); /* TXD0 */ pin_mask |= (1 << 14); /* TXD1 */ pin_mask |= (1 << 11); /* TXEN */ pin_mask |= (1 << 12); /* TXCK */ pin_mask |= (1 << 10); /* RXD0 */ pin_mask |= (1 << 6); /* RXD1 */ pin_mask |= (1 << 5); /* RXER */ pin_mask |= (1 << 4); /* RXDV */ pin_mask |= (1 << 3); /* MDC */ pin_mask |= (1 << 2); /* MDIO */ |
198f29358 avr32: Fix MIMC20... |
1089 |
#ifndef CONFIG_BOARD_MIMC200 |
caf18f19e avr32: Allow sele... |
1090 1091 |
if (!data->is_rmii) pin_mask |= (1 << 15); /* SPD */ |
198f29358 avr32: Fix MIMC20... |
1092 |
#endif |
caf18f19e avr32: Allow sele... |
1093 1094 |
select_peripheral(PIOD, pin_mask, PERIPH_B, 0); |
cfcb3a89d [AVR32] Add macb1... |
1095 1096 |
if (!data->is_rmii) { |
caf18f19e avr32: Allow sele... |
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 |
pin_mask = (1 << 19); /* COL */ pin_mask |= (1 << 23); /* CRS */ pin_mask |= (1 << 26); /* TXER */ pin_mask |= (1 << 27); /* TXD2 */ pin_mask |= (1 << 28); /* TXD3 */ pin_mask |= (1 << 29); /* RXD2 */ pin_mask |= (1 << 30); /* RXD3 */ pin_mask |= (1 << 24); /* RXCK */ select_peripheral(PIOC, pin_mask, PERIPH_B, 0); |
cfcb3a89d [AVR32] Add macb1... |
1107 1108 |
} break; |
5f97f7f94 [PATCH] avr32 arc... |
1109 1110 1111 |
default: return NULL; } |
84e0cdb0a macb: unify at91 ... |
1112 |
memcpy(pdev->dev.platform_data, data, sizeof(struct macb_platform_data)); |
5f97f7f94 [PATCH] avr32 arc... |
1113 1114 1115 1116 |
platform_device_register(pdev); return pdev; } |
438ff3f3c [AVR32] Add suppo... |
1117 |
#endif |
5f97f7f94 [PATCH] avr32 arc... |
1118 1119 1120 1121 |
/* -------------------------------------------------------------------- * SPI * -------------------------------------------------------------------- */ |
3d60ee1b0 [AVR32] SPI platf... |
1122 |
static struct resource atmel_spi0_resource[] = { |
5f97f7f94 [PATCH] avr32 arc... |
1123 1124 1125 |
PBMEM(0xffe00000), IRQ(3), }; |
3d60ee1b0 [AVR32] SPI platf... |
1126 1127 1128 1129 1130 1131 1132 1133 1134 |
DEFINE_DEV(atmel_spi, 0); DEV_CLK(spi_clk, atmel_spi0, pba, 0); static struct resource atmel_spi1_resource[] = { PBMEM(0xffe00400), IRQ(4), }; DEFINE_DEV(atmel_spi, 1); DEV_CLK(spi_clk, atmel_spi1, pba, 1); |
5f97f7f94 [PATCH] avr32 arc... |
1135 |
|
070842037 avr32: function f... |
1136 1137 |
void __init at32_spi_setup_slaves(unsigned int bus_num, struct spi_board_info *b, unsigned int n) |
5f97f7f94 [PATCH] avr32 arc... |
1138 |
{ |
070842037 avr32: function f... |
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 |
/* * Manage the chipselects as GPIOs, normally using the same pins * the SPI controller expects; but boards can use other pins. */ static u8 __initdata spi_pins[][4] = { { GPIO_PIN_PA(3), GPIO_PIN_PA(4), GPIO_PIN_PA(5), GPIO_PIN_PA(20) }, { GPIO_PIN_PB(2), GPIO_PIN_PB(3), GPIO_PIN_PB(4), GPIO_PIN_PA(27) }, }; |
41d8ca452 [AVR32] Use per-c... |
1149 |
unsigned int pin, mode; |
070842037 avr32: function f... |
1150 1151 1152 |
/* There are only 2 SPI controllers */ if (bus_num > 1) return; |
41d8ca452 [AVR32] Use per-c... |
1153 1154 1155 1156 1157 1158 |
for (; n; n--, b++) { b->bus_num = bus_num; if (b->chip_select >= 4) continue; pin = (unsigned)b->controller_data; if (!pin) { |
070842037 avr32: function f... |
1159 |
pin = spi_pins[bus_num][b->chip_select]; |
41d8ca452 [AVR32] Use per-c... |
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 |
b->controller_data = (void *)pin; } mode = AT32_GPIOF_OUTPUT; if (!(b->mode & SPI_CS_HIGH)) mode |= AT32_GPIOF_HIGH; at32_select_gpio(pin, mode); } } struct platform_device *__init at32_add_device_spi(unsigned int id, struct spi_board_info *b, unsigned int n) { |
5f97f7f94 [PATCH] avr32 arc... |
1172 |
struct platform_device *pdev; |
caf18f19e avr32: Allow sele... |
1173 |
u32 pin_mask; |
5f97f7f94 [PATCH] avr32 arc... |
1174 1175 1176 |
switch (id) { case 0: |
3d60ee1b0 [AVR32] SPI platf... |
1177 |
pdev = &atmel_spi0_device; |
caf18f19e avr32: Allow sele... |
1178 |
pin_mask = (1 << 1) | (1 << 2); /* MOSI & SCK */ |
9c2baf785 at32ap700x spi: e... |
1179 |
/* pullup MISO so a level is always defined */ |
caf18f19e avr32: Allow sele... |
1180 1181 |
select_peripheral(PIOA, (1 << 0), PERIPH_A, AT32_GPIOF_PULLUP); select_peripheral(PIOA, pin_mask, PERIPH_A, 0); |
070842037 avr32: function f... |
1182 |
at32_spi_setup_slaves(0, b, n); |
3d60ee1b0 [AVR32] SPI platf... |
1183 1184 1185 1186 |
break; case 1: pdev = &atmel_spi1_device; |
caf18f19e avr32: Allow sele... |
1187 |
pin_mask = (1 << 1) | (1 << 5); /* MOSI */ |
9c2baf785 at32ap700x spi: e... |
1188 |
/* pullup MISO so a level is always defined */ |
caf18f19e avr32: Allow sele... |
1189 1190 |
select_peripheral(PIOB, (1 << 0), PERIPH_B, AT32_GPIOF_PULLUP); select_peripheral(PIOB, pin_mask, PERIPH_B, 0); |
070842037 avr32: function f... |
1191 |
at32_spi_setup_slaves(1, b, n); |
5f97f7f94 [PATCH] avr32 arc... |
1192 1193 1194 1195 1196 |
break; default: return NULL; } |
41d8ca452 [AVR32] Use per-c... |
1197 |
spi_register_board_info(b, n); |
5f97f7f94 [PATCH] avr32 arc... |
1198 1199 1200 1201 1202 |
platform_device_register(pdev); return pdev; } /* -------------------------------------------------------------------- |
2042c1c4e [AVR32] Implement... |
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 |
* TWI * -------------------------------------------------------------------- */ static struct resource atmel_twi0_resource[] __initdata = { PBMEM(0xffe00800), IRQ(5), }; static struct clk atmel_twi0_pclk = { .name = "twi_pclk", .parent = &pba_clk, .mode = pba_clk_mode, .get_rate = pba_clk_get_rate, .index = 2, }; |
040b28fc0 avr32: pass i2c b... |
1216 1217 1218 |
struct platform_device *__init at32_add_device_twi(unsigned int id, struct i2c_board_info *b, unsigned int n) |
2042c1c4e [AVR32] Implement... |
1219 1220 |
{ struct platform_device *pdev; |
caf18f19e avr32: Allow sele... |
1221 |
u32 pin_mask; |
2042c1c4e [AVR32] Implement... |
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 |
if (id != 0) return NULL; pdev = platform_device_alloc("atmel_twi", id); if (!pdev) return NULL; if (platform_device_add_resources(pdev, atmel_twi0_resource, ARRAY_SIZE(atmel_twi0_resource))) goto err_add_resources; |
caf18f19e avr32: Allow sele... |
1233 1234 1235 |
pin_mask = (1 << 6) | (1 << 7); /* SDA & SDL */ select_peripheral(PIOA, pin_mask, PERIPH_A, 0); |
2042c1c4e [AVR32] Implement... |
1236 1237 |
atmel_twi0_pclk.dev = &pdev->dev; |
040b28fc0 avr32: pass i2c b... |
1238 1239 |
if (b) i2c_register_board_info(id, b, n); |
2042c1c4e [AVR32] Implement... |
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 |
platform_device_add(pdev); return pdev; err_add_resources: platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- * MMC * -------------------------------------------------------------------- */ static struct resource atmel_mci0_resource[] __initdata = { PBMEM(0xfff02400), IRQ(28), }; static struct clk atmel_mci0_pclk = { .name = "mci_clk", .parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .index = 9, }; |
7d2be0749 atmel-mci: Driver... |
1262 1263 |
struct platform_device *__init at32_add_device_mci(unsigned int id, struct mci_platform_data *data) |
2042c1c4e [AVR32] Implement... |
1264 |
{ |
7d2be0749 atmel-mci: Driver... |
1265 |
struct platform_device *pdev; |
754a00aeb arch/avr32: Fix b... |
1266 |
struct mci_dma_data *slave; |
caf18f19e avr32: Allow sele... |
1267 1268 |
u32 pioa_mask; u32 piob_mask; |
2042c1c4e [AVR32] Implement... |
1269 |
|
6b918657b atmel-mci: Platfo... |
1270 1271 1272 1273 1274 |
if (id != 0 || !data) return NULL; /* Must have at least one usable slot */ if (!data->slot[0].bus_width && !data->slot[1].bus_width) |
2042c1c4e [AVR32] Implement... |
1275 1276 1277 1278 |
return NULL; pdev = platform_device_alloc("atmel_mci", id); if (!pdev) |
7d2be0749 atmel-mci: Driver... |
1279 |
goto fail; |
2042c1c4e [AVR32] Implement... |
1280 1281 1282 |
if (platform_device_add_resources(pdev, atmel_mci0_resource, ARRAY_SIZE(atmel_mci0_resource))) |
7d2be0749 atmel-mci: Driver... |
1283 |
goto fail; |
754a00aeb arch/avr32: Fix b... |
1284 |
slave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL); |
cbf8de162 avr32: clean up m... |
1285 1286 |
if (!slave) goto fail; |
2635d1ba7 atmel-mci: change... |
1287 1288 1289 1290 |
slave->sdata.dma_dev = &dw_dmac0_device.dev; slave->sdata.reg_width = DW_DMA_SLAVE_WIDTH_32BIT; slave->sdata.cfg_hi = (DWC_CFGH_SRC_PER(0) |
65e8b083f atmel-mci: Add ex... |
1291 |
| DWC_CFGH_DST_PER(1)); |
2635d1ba7 atmel-mci: change... |
1292 |
slave->sdata.cfg_lo &= ~(DWC_CFGL_HS_DST_POL |
65e8b083f atmel-mci: Add ex... |
1293 |
| DWC_CFGL_HS_SRC_POL); |
2635d1ba7 atmel-mci: change... |
1294 |
data->dma_slave = slave; |
7d2be0749 atmel-mci: Driver... |
1295 1296 |
if (platform_device_add_data(pdev, data, sizeof(struct mci_platform_data))) |
cbf8de162 avr32: clean up m... |
1297 |
goto fail_free; |
2042c1c4e [AVR32] Implement... |
1298 |
|
6b918657b atmel-mci: Platfo... |
1299 |
/* CLK line is common to both slots */ |
caf18f19e avr32: Allow sele... |
1300 |
pioa_mask = 1 << 10; |
6b918657b atmel-mci: Platfo... |
1301 1302 1303 |
switch (data->slot[0].bus_width) { case 4: |
caf18f19e avr32: Allow sele... |
1304 1305 1306 |
pioa_mask |= 1 << 13; /* DATA1 */ pioa_mask |= 1 << 14; /* DATA2 */ pioa_mask |= 1 << 15; /* DATA3 */ |
6b918657b atmel-mci: Platfo... |
1307 1308 |
/* fall through */ case 1: |
caf18f19e avr32: Allow sele... |
1309 1310 |
pioa_mask |= 1 << 11; /* CMD */ pioa_mask |= 1 << 12; /* DATA0 */ |
6b918657b atmel-mci: Platfo... |
1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
if (gpio_is_valid(data->slot[0].detect_pin)) at32_select_gpio(data->slot[0].detect_pin, 0); if (gpio_is_valid(data->slot[0].wp_pin)) at32_select_gpio(data->slot[0].wp_pin, 0); break; case 0: /* Slot is unused */ break; default: |
cbf8de162 avr32: clean up m... |
1321 |
goto fail_free; |
6b918657b atmel-mci: Platfo... |
1322 |
} |
caf18f19e avr32: Allow sele... |
1323 1324 |
select_peripheral(PIOA, pioa_mask, PERIPH_A, 0); piob_mask = 0; |
6b918657b atmel-mci: Platfo... |
1325 1326 |
switch (data->slot[1].bus_width) { case 4: |
caf18f19e avr32: Allow sele... |
1327 1328 1329 |
piob_mask |= 1 << 8; /* DATA1 */ piob_mask |= 1 << 9; /* DATA2 */ piob_mask |= 1 << 10; /* DATA3 */ |
6b918657b atmel-mci: Platfo... |
1330 1331 |
/* fall through */ case 1: |
caf18f19e avr32: Allow sele... |
1332 1333 1334 |
piob_mask |= 1 << 6; /* CMD */ piob_mask |= 1 << 7; /* DATA0 */ select_peripheral(PIOB, piob_mask, PERIPH_B, 0); |
6b918657b atmel-mci: Platfo... |
1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 |
if (gpio_is_valid(data->slot[1].detect_pin)) at32_select_gpio(data->slot[1].detect_pin, 0); if (gpio_is_valid(data->slot[1].wp_pin)) at32_select_gpio(data->slot[1].wp_pin, 0); break; case 0: /* Slot is unused */ break; default: if (!data->slot[0].bus_width) |
cbf8de162 avr32: clean up m... |
1346 |
goto fail_free; |
6b918657b atmel-mci: Platfo... |
1347 1348 1349 1350 |
data->slot[1].bus_width = 0; break; } |
7d2be0749 atmel-mci: Driver... |
1351 |
|
2042c1c4e [AVR32] Implement... |
1352 1353 1354 1355 |
atmel_mci0_pclk.dev = &pdev->dev; platform_device_add(pdev); return pdev; |
cbf8de162 avr32: clean up m... |
1356 1357 |
fail_free: kfree(slave); |
7d2be0749 atmel-mci: Driver... |
1358 |
fail: |
2635d1ba7 atmel-mci: change... |
1359 |
data->dma_slave = NULL; |
2042c1c4e [AVR32] Implement... |
1360 1361 1362 1363 1364 |
platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- |
5f97f7f94 [PATCH] avr32 arc... |
1365 1366 |
* LCDC * -------------------------------------------------------------------- */ |
438ff3f3c [AVR32] Add suppo... |
1367 |
#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002) |
d0a2b7af2 [AVR32] Implement... |
1368 1369 |
static struct atmel_lcdfb_info atmel_lcdfb0_data; static struct resource atmel_lcdfb0_resource[] = { |
5f97f7f94 [PATCH] avr32 arc... |
1370 1371 1372 1373 1374 1375 |
{ .start = 0xff000000, .end = 0xff000fff, .flags = IORESOURCE_MEM, }, IRQ(1), |
d0a2b7af2 [AVR32] Implement... |
1376 1377 1378 1379 1380 1381 |
{ /* Placeholder for pre-allocated fb memory */ .start = 0x00000000, .end = 0x00000000, .flags = 0, }, |
5f97f7f94 [PATCH] avr32 arc... |
1382 |
}; |
d0a2b7af2 [AVR32] Implement... |
1383 1384 1385 1386 1387 |
DEFINE_DEV_DATA(atmel_lcdfb, 0); DEV_CLK(hck1, atmel_lcdfb0, hsb, 7); static struct clk atmel_lcdfb0_pixclk = { .name = "lcdc_clk", .dev = &atmel_lcdfb0_device.dev, |
5f97f7f94 [PATCH] avr32 arc... |
1388 1389 1390 1391 1392 1393 1394 1395 |
.mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 7, }; struct platform_device *__init |
d0a2b7af2 [AVR32] Implement... |
1396 |
at32_add_device_lcdc(unsigned int id, struct atmel_lcdfb_info *data, |
47882cf62 avr32: Add pin co... |
1397 |
unsigned long fbmem_start, unsigned long fbmem_len, |
706641248 avr32: Allow fine... |
1398 |
u64 pin_mask) |
5f97f7f94 [PATCH] avr32 arc... |
1399 1400 |
{ struct platform_device *pdev; |
d0a2b7af2 [AVR32] Implement... |
1401 1402 1403 1404 |
struct atmel_lcdfb_info *info; struct fb_monspecs *monspecs; struct fb_videomode *modedb; unsigned int modedb_size; |
caf18f19e avr32: Allow sele... |
1405 |
u32 portc_mask, portd_mask, porte_mask; |
d0a2b7af2 [AVR32] Implement... |
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 |
/* * Do a deep copy of the fb data, monspecs and modedb. Make * sure all allocations are done before setting up the * portmux. */ monspecs = kmemdup(data->default_monspecs, sizeof(struct fb_monspecs), GFP_KERNEL); if (!monspecs) return NULL; modedb_size = sizeof(struct fb_videomode) * monspecs->modedb_len; modedb = kmemdup(monspecs->modedb, modedb_size, GFP_KERNEL); if (!modedb) goto err_dup_modedb; monspecs->modedb = modedb; |
5f97f7f94 [PATCH] avr32 arc... |
1422 1423 1424 |
switch (id) { case 0: |
d0a2b7af2 [AVR32] Implement... |
1425 |
pdev = &atmel_lcdfb0_device; |
47882cf62 avr32: Add pin co... |
1426 |
|
706641248 avr32: Allow fine... |
1427 1428 1429 1430 1431 |
if (pin_mask == 0ULL) /* Default to "full" lcdc control signals and 24bit */ pin_mask = ATMEL_LCDC_PRI_24BIT | ATMEL_LCDC_PRI_CONTROL; /* LCDC on port C */ |
609006566 avr32: Fix bug in... |
1432 |
portc_mask = pin_mask & 0xfff80000; |
caf18f19e avr32: Allow sele... |
1433 |
select_peripheral(PIOC, portc_mask, PERIPH_A, 0); |
706641248 avr32: Allow fine... |
1434 1435 |
/* LCDC on port D */ |
caf18f19e avr32: Allow sele... |
1436 1437 |
portd_mask = pin_mask & 0x0003ffff; select_peripheral(PIOD, portd_mask, PERIPH_A, 0); |
706641248 avr32: Allow fine... |
1438 1439 |
/* LCDC on port E */ |
caf18f19e avr32: Allow sele... |
1440 1441 |
porte_mask = (pin_mask >> 32) & 0x0007ffff; select_peripheral(PIOE, porte_mask, PERIPH_B, 0); |
5f97f7f94 [PATCH] avr32 arc... |
1442 |
|
d0a2b7af2 [AVR32] Implement... |
1443 1444 |
clk_set_parent(&atmel_lcdfb0_pixclk, &pll0); clk_set_rate(&atmel_lcdfb0_pixclk, clk_get_rate(&pll0)); |
5f97f7f94 [PATCH] avr32 arc... |
1445 1446 1447 |
break; default: |
d0a2b7af2 [AVR32] Implement... |
1448 |
goto err_invalid_id; |
5f97f7f94 [PATCH] avr32 arc... |
1449 |
} |
d0a2b7af2 [AVR32] Implement... |
1450 1451 1452 1453 1454 1455 1456 1457 1458 |
if (fbmem_len) { pdev->resource[2].start = fbmem_start; pdev->resource[2].end = fbmem_start + fbmem_len - 1; pdev->resource[2].flags = IORESOURCE_MEM; } info = pdev->dev.platform_data; memcpy(info, data, sizeof(struct atmel_lcdfb_info)); info->default_monspecs = monspecs; |
5f97f7f94 [PATCH] avr32 arc... |
1459 1460 1461 |
platform_device_register(pdev); return pdev; |
d0a2b7af2 [AVR32] Implement... |
1462 1463 1464 1465 1466 1467 |
err_invalid_id: kfree(modedb); err_dup_modedb: kfree(monspecs); return NULL; |
5f97f7f94 [PATCH] avr32 arc... |
1468 |
} |
438ff3f3c [AVR32] Add suppo... |
1469 |
#endif |
5f97f7f94 [PATCH] avr32 arc... |
1470 |
|
7a5fe2387 [AVR32] Make sure... |
1471 |
/* -------------------------------------------------------------------- |
9a1e8eb1f Basic PWM driver ... |
1472 1473 1474 1475 1476 1477 1478 |
* PWM * -------------------------------------------------------------------- */ static struct resource atmel_pwm0_resource[] __initdata = { PBMEM(0xfff01400), IRQ(24), }; static struct clk atmel_pwm0_mck = { |
8405996ff atmel_pwm: Rename... |
1479 |
.name = "pwm_clk", |
9a1e8eb1f Basic PWM driver ... |
1480 1481 1482 1483 1484 1485 1486 1487 1488 |
.parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .index = 5, }; struct platform_device *__init at32_add_device_pwm(u32 mask) { struct platform_device *pdev; |
caf18f19e avr32: Allow sele... |
1489 |
u32 pin_mask; |
9a1e8eb1f Basic PWM driver ... |
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 |
if (!mask) return NULL; pdev = platform_device_alloc("atmel_pwm", 0); if (!pdev) return NULL; if (platform_device_add_resources(pdev, atmel_pwm0_resource, ARRAY_SIZE(atmel_pwm0_resource))) goto out_free_pdev; if (platform_device_add_data(pdev, &mask, sizeof(mask))) goto out_free_pdev; |
caf18f19e avr32: Allow sele... |
1504 |
pin_mask = 0; |
9a1e8eb1f Basic PWM driver ... |
1505 |
if (mask & (1 << 0)) |
caf18f19e avr32: Allow sele... |
1506 |
pin_mask |= (1 << 28); |
9a1e8eb1f Basic PWM driver ... |
1507 |
if (mask & (1 << 1)) |
caf18f19e avr32: Allow sele... |
1508 1509 1510 1511 1512 |
pin_mask |= (1 << 29); if (pin_mask > 0) select_peripheral(PIOA, pin_mask, PERIPH_A, 0); pin_mask = 0; |
9a1e8eb1f Basic PWM driver ... |
1513 |
if (mask & (1 << 2)) |
caf18f19e avr32: Allow sele... |
1514 |
pin_mask |= (1 << 21); |
9a1e8eb1f Basic PWM driver ... |
1515 |
if (mask & (1 << 3)) |
caf18f19e avr32: Allow sele... |
1516 1517 1518 |
pin_mask |= (1 << 22); if (pin_mask > 0) select_peripheral(PIOA, pin_mask, PERIPH_B, 0); |
9a1e8eb1f Basic PWM driver ... |
1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 |
atmel_pwm0_mck.dev = &pdev->dev; platform_device_add(pdev); return pdev; out_free_pdev: platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- |
9cf6cf58d [AVR32] Add Atmel... |
1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 |
* SSC * -------------------------------------------------------------------- */ static struct resource ssc0_resource[] = { PBMEM(0xffe01c00), IRQ(10), }; DEFINE_DEV(ssc, 0); DEV_CLK(pclk, ssc0, pba, 7); static struct resource ssc1_resource[] = { PBMEM(0xffe02000), IRQ(11), }; DEFINE_DEV(ssc, 1); DEV_CLK(pclk, ssc1, pba, 8); static struct resource ssc2_resource[] = { PBMEM(0xffe02400), IRQ(12), }; DEFINE_DEV(ssc, 2); DEV_CLK(pclk, ssc2, pba, 9); struct platform_device *__init at32_add_device_ssc(unsigned int id, unsigned int flags) { struct platform_device *pdev; |
caf18f19e avr32: Allow sele... |
1559 |
u32 pin_mask = 0; |
9cf6cf58d [AVR32] Add Atmel... |
1560 1561 1562 1563 1564 |
switch (id) { case 0: pdev = &ssc0_device; if (flags & ATMEL_SSC_RF) |
caf18f19e avr32: Allow sele... |
1565 |
pin_mask |= (1 << 21); /* RF */ |
9cf6cf58d [AVR32] Add Atmel... |
1566 |
if (flags & ATMEL_SSC_RK) |
caf18f19e avr32: Allow sele... |
1567 |
pin_mask |= (1 << 22); /* RK */ |
9cf6cf58d [AVR32] Add Atmel... |
1568 |
if (flags & ATMEL_SSC_TK) |
caf18f19e avr32: Allow sele... |
1569 |
pin_mask |= (1 << 23); /* TK */ |
9cf6cf58d [AVR32] Add Atmel... |
1570 |
if (flags & ATMEL_SSC_TF) |
caf18f19e avr32: Allow sele... |
1571 |
pin_mask |= (1 << 24); /* TF */ |
9cf6cf58d [AVR32] Add Atmel... |
1572 |
if (flags & ATMEL_SSC_TD) |
caf18f19e avr32: Allow sele... |
1573 |
pin_mask |= (1 << 25); /* TD */ |
9cf6cf58d [AVR32] Add Atmel... |
1574 |
if (flags & ATMEL_SSC_RD) |
caf18f19e avr32: Allow sele... |
1575 1576 1577 1578 |
pin_mask |= (1 << 26); /* RD */ if (pin_mask > 0) select_peripheral(PIOA, pin_mask, PERIPH_A, 0); |
9cf6cf58d [AVR32] Add Atmel... |
1579 1580 1581 1582 |
break; case 1: pdev = &ssc1_device; if (flags & ATMEL_SSC_RF) |
caf18f19e avr32: Allow sele... |
1583 |
pin_mask |= (1 << 0); /* RF */ |
9cf6cf58d [AVR32] Add Atmel... |
1584 |
if (flags & ATMEL_SSC_RK) |
caf18f19e avr32: Allow sele... |
1585 |
pin_mask |= (1 << 1); /* RK */ |
9cf6cf58d [AVR32] Add Atmel... |
1586 |
if (flags & ATMEL_SSC_TK) |
caf18f19e avr32: Allow sele... |
1587 |
pin_mask |= (1 << 2); /* TK */ |
9cf6cf58d [AVR32] Add Atmel... |
1588 |
if (flags & ATMEL_SSC_TF) |
caf18f19e avr32: Allow sele... |
1589 |
pin_mask |= (1 << 3); /* TF */ |
9cf6cf58d [AVR32] Add Atmel... |
1590 |
if (flags & ATMEL_SSC_TD) |
caf18f19e avr32: Allow sele... |
1591 |
pin_mask |= (1 << 4); /* TD */ |
9cf6cf58d [AVR32] Add Atmel... |
1592 |
if (flags & ATMEL_SSC_RD) |
caf18f19e avr32: Allow sele... |
1593 1594 1595 1596 |
pin_mask |= (1 << 5); /* RD */ if (pin_mask > 0) select_peripheral(PIOA, pin_mask, PERIPH_B, 0); |
9cf6cf58d [AVR32] Add Atmel... |
1597 1598 1599 1600 |
break; case 2: pdev = &ssc2_device; if (flags & ATMEL_SSC_TD) |
caf18f19e avr32: Allow sele... |
1601 |
pin_mask |= (1 << 13); /* TD */ |
9cf6cf58d [AVR32] Add Atmel... |
1602 |
if (flags & ATMEL_SSC_RD) |
caf18f19e avr32: Allow sele... |
1603 |
pin_mask |= (1 << 14); /* RD */ |
9cf6cf58d [AVR32] Add Atmel... |
1604 |
if (flags & ATMEL_SSC_TK) |
caf18f19e avr32: Allow sele... |
1605 |
pin_mask |= (1 << 15); /* TK */ |
9cf6cf58d [AVR32] Add Atmel... |
1606 |
if (flags & ATMEL_SSC_TF) |
caf18f19e avr32: Allow sele... |
1607 |
pin_mask |= (1 << 16); /* TF */ |
9cf6cf58d [AVR32] Add Atmel... |
1608 |
if (flags & ATMEL_SSC_RF) |
caf18f19e avr32: Allow sele... |
1609 |
pin_mask |= (1 << 17); /* RF */ |
9cf6cf58d [AVR32] Add Atmel... |
1610 |
if (flags & ATMEL_SSC_RK) |
caf18f19e avr32: Allow sele... |
1611 1612 1613 1614 |
pin_mask |= (1 << 18); /* RK */ if (pin_mask > 0) select_peripheral(PIOB, pin_mask, PERIPH_A, 0); |
9cf6cf58d [AVR32] Add Atmel... |
1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 |
break; default: return NULL; } platform_device_register(pdev); return pdev; } /* -------------------------------------------------------------------- |
6fcf06151 [AVR32] Wire up U... |
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 |
* USB Device Controller * -------------------------------------------------------------------- */ static struct resource usba0_resource[] __initdata = { { .start = 0xff300000, .end = 0xff3fffff, .flags = IORESOURCE_MEM, }, { .start = 0xfff03000, .end = 0xfff033ff, .flags = IORESOURCE_MEM, }, IRQ(31), }; static struct clk usba0_pclk = { .name = "pclk", .parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .index = 12, }; static struct clk usba0_hclk = { .name = "hclk", .parent = &hsb_clk, .mode = hsb_clk_mode, .get_rate = hsb_clk_get_rate, .index = 6, }; |
8d855317f atmel_usba_udc: m... |
1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 |
#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \ [idx] = { \ .name = nam, \ .index = idx, \ .fifo_size = maxpkt, \ .nr_banks = maxbk, \ .can_dma = dma, \ .can_isoc = isoc, \ } static struct usba_ep_data at32_usba_ep[] __initdata = { EP("ep0", 0, 64, 1, 0, 0), EP("ep1", 1, 512, 2, 1, 1), EP("ep2", 2, 512, 2, 1, 1), EP("ep3-int", 3, 64, 3, 1, 0), EP("ep4-int", 4, 64, 3, 1, 0), EP("ep5", 5, 1024, 3, 1, 1), EP("ep6", 6, 1024, 3, 1, 1), }; #undef EP |
6fcf06151 [AVR32] Wire up U... |
1674 1675 1676 |
struct platform_device *__init at32_add_device_usba(unsigned int id, struct usba_platform_data *data) { |
8d855317f atmel_usba_udc: m... |
1677 1678 1679 1680 1681 1682 1683 1684 |
/* * pdata doesn't have room for any endpoints, so we need to * append room for the ones we need right after it. */ struct { struct usba_platform_data pdata; struct usba_ep_data ep[7]; } usba_data; |
6fcf06151 [AVR32] Wire up U... |
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 |
struct platform_device *pdev; if (id != 0) return NULL; pdev = platform_device_alloc("atmel_usba_udc", 0); if (!pdev) return NULL; if (platform_device_add_resources(pdev, usba0_resource, ARRAY_SIZE(usba0_resource))) goto out_free_pdev; |
640e95abd USB: atmel uaba: ... |
1697 |
if (data) { |
8d855317f atmel_usba_udc: m... |
1698 |
usba_data.pdata.vbus_pin = data->vbus_pin; |
640e95abd USB: atmel uaba: ... |
1699 1700 |
usba_data.pdata.vbus_pin_inverted = data->vbus_pin_inverted; } else { |
8d855317f atmel_usba_udc: m... |
1701 |
usba_data.pdata.vbus_pin = -EINVAL; |
640e95abd USB: atmel uaba: ... |
1702 1703 |
usba_data.pdata.vbus_pin_inverted = -EINVAL; } |
6fcf06151 [AVR32] Wire up U... |
1704 |
|
8d855317f atmel_usba_udc: m... |
1705 1706 1707 1708 1709 1710 |
data = &usba_data.pdata; data->num_ep = ARRAY_SIZE(at32_usba_ep); memcpy(data->ep, at32_usba_ep, sizeof(at32_usba_ep)); if (platform_device_add_data(pdev, data, sizeof(usba_data))) goto out_free_pdev; |
9477ab2b2 avr32: use gpio_i... |
1711 |
if (gpio_is_valid(data->vbus_pin)) |
8d855317f atmel_usba_udc: m... |
1712 |
at32_select_gpio(data->vbus_pin, 0); |
6fcf06151 [AVR32] Wire up U... |
1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 |
usba0_pclk.dev = &pdev->dev; usba0_hclk.dev = &pdev->dev; platform_device_add(pdev); return pdev; out_free_pdev: platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- |
eaf5f925a [AVR32] Implement... |
1727 |
* IDE / CompactFlash |
48021bd93 [AVR32] Platform ... |
1728 |
* -------------------------------------------------------------------- */ |
438ff3f3c [AVR32] Add suppo... |
1729 |
#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7001) |
eaf5f925a [AVR32] Implement... |
1730 |
static struct resource at32_smc_cs4_resource[] __initdata = { |
48021bd93 [AVR32] Platform ... |
1731 1732 1733 1734 1735 1736 1737 |
{ .start = 0x04000000, .end = 0x07ffffff, .flags = IORESOURCE_MEM, }, IRQ(~0UL), /* Magic IRQ will be overridden */ }; |
eaf5f925a [AVR32] Implement... |
1738 1739 1740 1741 1742 1743 1744 1745 |
static struct resource at32_smc_cs5_resource[] __initdata = { { .start = 0x20000000, .end = 0x23ffffff, .flags = IORESOURCE_MEM, }, IRQ(~0UL), /* Magic IRQ will be overridden */ }; |
48021bd93 [AVR32] Platform ... |
1746 |
|
eaf5f925a [AVR32] Implement... |
1747 1748 |
static int __init at32_init_ide_or_cf(struct platform_device *pdev, unsigned int cs, unsigned int extint) |
48021bd93 [AVR32] Platform ... |
1749 |
{ |
eaf5f925a [AVR32] Implement... |
1750 |
static unsigned int extint_pin_map[4] __initdata = { |
caf18f19e avr32: Allow sele... |
1751 1752 1753 1754 |
(1 << 25), (1 << 26), (1 << 27), (1 << 28), |
eaf5f925a [AVR32] Implement... |
1755 1756 |
}; static bool common_pins_initialized __initdata = false; |
48021bd93 [AVR32] Platform ... |
1757 |
unsigned int extint_pin; |
eaf5f925a [AVR32] Implement... |
1758 |
int ret; |
caf18f19e avr32: Allow sele... |
1759 |
u32 pin_mask; |
48021bd93 [AVR32] Platform ... |
1760 |
|
eaf5f925a [AVR32] Implement... |
1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 |
if (extint >= ARRAY_SIZE(extint_pin_map)) return -EINVAL; extint_pin = extint_pin_map[extint]; switch (cs) { case 4: ret = platform_device_add_resources(pdev, at32_smc_cs4_resource, ARRAY_SIZE(at32_smc_cs4_resource)); if (ret) return ret; |
caf18f19e avr32: Allow sele... |
1772 1773 |
/* NCS4 -> OE_N */ select_peripheral(PIOE, (1 << 21), PERIPH_A, 0); |
b47eb4092 avr32: Clean up H... |
1774 |
hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_CF0_ENABLE); |
48021bd93 [AVR32] Platform ... |
1775 |
break; |
eaf5f925a [AVR32] Implement... |
1776 1777 1778 1779 1780 1781 |
case 5: ret = platform_device_add_resources(pdev, at32_smc_cs5_resource, ARRAY_SIZE(at32_smc_cs5_resource)); if (ret) return ret; |
caf18f19e avr32: Allow sele... |
1782 1783 |
/* NCS5 -> OE_N */ select_peripheral(PIOE, (1 << 22), PERIPH_A, 0); |
b47eb4092 avr32: Clean up H... |
1784 |
hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_CF1_ENABLE); |
48021bd93 [AVR32] Platform ... |
1785 1786 |
break; default: |
eaf5f925a [AVR32] Implement... |
1787 |
return -EINVAL; |
48021bd93 [AVR32] Platform ... |
1788 |
} |
eaf5f925a [AVR32] Implement... |
1789 |
if (!common_pins_initialized) { |
caf18f19e avr32: Allow sele... |
1790 1791 1792 1793 1794 1795 |
pin_mask = (1 << 19); /* CFCE1 -> CS0_N */ pin_mask |= (1 << 20); /* CFCE2 -> CS1_N */ pin_mask |= (1 << 23); /* CFRNW -> DIR */ pin_mask |= (1 << 24); /* NWAIT <- IORDY */ select_peripheral(PIOE, pin_mask, PERIPH_A, 0); |
eaf5f925a [AVR32] Implement... |
1796 |
common_pins_initialized = true; |
48021bd93 [AVR32] Platform ... |
1797 |
} |
caf18f19e avr32: Allow sele... |
1798 |
select_peripheral(PIOB, extint_pin, PERIPH_A, AT32_GPIOF_DEGLITCH); |
48021bd93 [AVR32] Platform ... |
1799 1800 1801 |
pdev->resource[1].start = EIM_IRQ_BASE + extint; pdev->resource[1].end = pdev->resource[1].start; |
eaf5f925a [AVR32] Implement... |
1802 1803 |
return 0; } |
48021bd93 [AVR32] Platform ... |
1804 |
|
eaf5f925a [AVR32] Implement... |
1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 |
struct platform_device *__init at32_add_device_ide(unsigned int id, unsigned int extint, struct ide_platform_data *data) { struct platform_device *pdev; pdev = platform_device_alloc("at32_ide", id); if (!pdev) goto fail; if (platform_device_add_data(pdev, data, sizeof(struct ide_platform_data))) goto fail; if (at32_init_ide_or_cf(pdev, data->cs, extint)) goto fail; platform_device_add(pdev); return pdev; fail: platform_device_put(pdev); return NULL; } struct platform_device *__init at32_add_device_cf(unsigned int id, unsigned int extint, struct cf_platform_data *data) { struct platform_device *pdev; pdev = platform_device_alloc("at32_cf", id); if (!pdev) goto fail; |
48021bd93 [AVR32] Platform ... |
1839 |
|
eaf5f925a [AVR32] Implement... |
1840 1841 1842 1843 1844 1845 |
if (platform_device_add_data(pdev, data, sizeof(struct cf_platform_data))) goto fail; if (at32_init_ide_or_cf(pdev, data->cs, extint)) goto fail; |
3c26e1703 avr32: some mmc/s... |
1846 |
if (gpio_is_valid(data->detect_pin)) |
eaf5f925a [AVR32] Implement... |
1847 |
at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); |
3c26e1703 avr32: some mmc/s... |
1848 |
if (gpio_is_valid(data->reset_pin)) |
eaf5f925a [AVR32] Implement... |
1849 |
at32_select_gpio(data->reset_pin, 0); |
3c26e1703 avr32: some mmc/s... |
1850 |
if (gpio_is_valid(data->vcc_pin)) |
eaf5f925a [AVR32] Implement... |
1851 1852 1853 1854 |
at32_select_gpio(data->vcc_pin, 0); /* READY is used as extint, so we can't select it as gpio */ platform_device_add(pdev); |
48021bd93 [AVR32] Platform ... |
1855 |
return pdev; |
eaf5f925a [AVR32] Implement... |
1856 1857 1858 1859 |
fail: platform_device_put(pdev); return NULL; |
48021bd93 [AVR32] Platform ... |
1860 |
} |
438ff3f3c [AVR32] Add suppo... |
1861 |
#endif |
48021bd93 [AVR32] Platform ... |
1862 1863 |
/* -------------------------------------------------------------------- |
62090a08a [MTD] [NAND] avr3... |
1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 |
* NAND Flash / SmartMedia * -------------------------------------------------------------------- */ static struct resource smc_cs3_resource[] __initdata = { { .start = 0x0c000000, .end = 0x0fffffff, .flags = IORESOURCE_MEM, }, { .start = 0xfff03c00, .end = 0xfff03fff, .flags = IORESOURCE_MEM, }, }; struct platform_device *__init at32_add_device_nand(unsigned int id, struct atmel_nand_data *data) { struct platform_device *pdev; if (id != 0 || !data) return NULL; pdev = platform_device_alloc("atmel_nand", id); if (!pdev) goto fail; if (platform_device_add_resources(pdev, smc_cs3_resource, ARRAY_SIZE(smc_cs3_resource))) goto fail; if (platform_device_add_data(pdev, data, sizeof(struct atmel_nand_data))) goto fail; |
b47eb4092 avr32: Clean up H... |
1897 |
hmatrix_sfr_set_bits(HMATRIX_SLAVE_EBI, HMATRIX_EBI_NAND_ENABLE); |
62090a08a [MTD] [NAND] avr3... |
1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 |
if (data->enable_pin) at32_select_gpio(data->enable_pin, AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); if (data->rdy_pin) at32_select_gpio(data->rdy_pin, 0); if (data->det_pin) at32_select_gpio(data->det_pin, 0); platform_device_add(pdev); return pdev; fail: platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- |
2042c1c4e [AVR32] Implement... |
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 |
* AC97C * -------------------------------------------------------------------- */ static struct resource atmel_ac97c0_resource[] __initdata = { PBMEM(0xfff02800), IRQ(29), }; static struct clk atmel_ac97c0_pclk = { .name = "pclk", .parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .index = 10, }; |
218df4a25 avr32: Add platfo... |
1928 |
struct platform_device *__init |
2f47c8c55 avr32: at32ap700x... |
1929 1930 |
at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data, unsigned int flags) |
2042c1c4e [AVR32] Implement... |
1931 |
{ |
2f47c8c55 avr32: at32ap700x... |
1932 1933 1934 1935 1936 |
struct platform_device *pdev; struct dw_dma_slave *rx_dws; struct dw_dma_slave *tx_dws; struct ac97c_platform_data _data; u32 pin_mask; |
2042c1c4e [AVR32] Implement... |
1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 |
if (id != 0) return NULL; pdev = platform_device_alloc("atmel_ac97c", id); if (!pdev) return NULL; if (platform_device_add_resources(pdev, atmel_ac97c0_resource, ARRAY_SIZE(atmel_ac97c0_resource))) |
2f47c8c55 avr32: at32ap700x... |
1947 |
goto out_free_resources; |
218df4a25 avr32: Add platfo... |
1948 1949 1950 1951 |
if (!data) { data = &_data; memset(data, 0, sizeof(struct ac97c_platform_data)); |
2f47c8c55 avr32: at32ap700x... |
1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 |
data->reset_pin = -ENODEV; } rx_dws = &data->rx_dws; tx_dws = &data->tx_dws; /* Check if DMA slave interface for capture should be configured. */ if (flags & AC97C_CAPTURE) { rx_dws->dma_dev = &dw_dmac0_device.dev; rx_dws->reg_width = DW_DMA_SLAVE_WIDTH_16BIT; rx_dws->cfg_hi = DWC_CFGH_SRC_PER(3); rx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL); |
4aa5f3664 avr32: at32ap700x... |
1964 1965 |
rx_dws->src_master = 0; rx_dws->dst_master = 1; |
1c5b0538c avr32: at32ap700x... |
1966 1967 1968 |
rx_dws->src_msize = DW_DMA_MSIZE_1; rx_dws->dst_msize = DW_DMA_MSIZE_1; rx_dws->fc = DW_DMA_FC_D_P2M; |
218df4a25 avr32: Add platfo... |
1969 |
} |
2f47c8c55 avr32: at32ap700x... |
1970 1971 1972 1973 1974 1975 |
/* Check if DMA slave interface for playback should be configured. */ if (flags & AC97C_PLAYBACK) { tx_dws->dma_dev = &dw_dmac0_device.dev; tx_dws->reg_width = DW_DMA_SLAVE_WIDTH_16BIT; tx_dws->cfg_hi = DWC_CFGH_DST_PER(4); tx_dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL); |
3ea205c44 avr32: at32ap700x... |
1976 1977 |
tx_dws->src_master = 0; tx_dws->dst_master = 1; |
1c5b0538c avr32: at32ap700x... |
1978 1979 1980 |
tx_dws->src_msize = DW_DMA_MSIZE_1; tx_dws->dst_msize = DW_DMA_MSIZE_1; tx_dws->fc = DW_DMA_FC_D_M2P; |
2f47c8c55 avr32: at32ap700x... |
1981 |
} |
2042c1c4e [AVR32] Implement... |
1982 |
|
218df4a25 avr32: Add platfo... |
1983 1984 |
if (platform_device_add_data(pdev, data, sizeof(struct ac97c_platform_data))) |
2f47c8c55 avr32: at32ap700x... |
1985 |
goto out_free_resources; |
218df4a25 avr32: Add platfo... |
1986 |
|
2f47c8c55 avr32: at32ap700x... |
1987 1988 |
/* SDO | SYNC | SCLK | SDI */ pin_mask = (1 << 20) | (1 << 21) | (1 << 22) | (1 << 23); |
caf18f19e avr32: Allow sele... |
1989 1990 |
select_peripheral(PIOB, pin_mask, PERIPH_B, 0); |
218df4a25 avr32: Add platfo... |
1991 |
|
2f47c8c55 avr32: at32ap700x... |
1992 1993 1994 |
if (gpio_is_valid(data->reset_pin)) at32_select_gpio(data->reset_pin, AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); |
2042c1c4e [AVR32] Implement... |
1995 1996 1997 1998 1999 |
atmel_ac97c0_pclk.dev = &pdev->dev; platform_device_add(pdev); return pdev; |
2f47c8c55 avr32: at32ap700x... |
2000 |
out_free_resources: |
2042c1c4e [AVR32] Implement... |
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 |
platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- * ABDAC * -------------------------------------------------------------------- */ static struct resource abdac0_resource[] __initdata = { PBMEM(0xfff02000), IRQ(27), }; static struct clk abdac0_pclk = { .name = "pclk", .parent = &pbb_clk, .mode = pbb_clk_mode, .get_rate = pbb_clk_get_rate, .index = 8, }; static struct clk abdac0_sample_clk = { .name = "sample_clk", .mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 6, }; |
6b0c93514 avr32: at32ap700x... |
2027 2028 |
struct platform_device *__init at32_add_device_abdac(unsigned int id, struct atmel_abdac_pdata *data) |
2042c1c4e [AVR32] Implement... |
2029 |
{ |
6b0c93514 avr32: at32ap700x... |
2030 2031 2032 |
struct platform_device *pdev; struct dw_dma_slave *dws; u32 pin_mask; |
2042c1c4e [AVR32] Implement... |
2033 |
|
6b0c93514 avr32: at32ap700x... |
2034 |
if (id != 0 || !data) |
2042c1c4e [AVR32] Implement... |
2035 |
return NULL; |
6b0c93514 avr32: at32ap700x... |
2036 |
pdev = platform_device_alloc("atmel_abdac", id); |
2042c1c4e [AVR32] Implement... |
2037 2038 2039 2040 2041 |
if (!pdev) return NULL; if (platform_device_add_resources(pdev, abdac0_resource, ARRAY_SIZE(abdac0_resource))) |
6b0c93514 avr32: at32ap700x... |
2042 2043 2044 2045 2046 2047 2048 2049 |
goto out_free_resources; dws = &data->dws; dws->dma_dev = &dw_dmac0_device.dev; dws->reg_width = DW_DMA_SLAVE_WIDTH_32BIT; dws->cfg_hi = DWC_CFGH_DST_PER(2); dws->cfg_lo &= ~(DWC_CFGL_HS_DST_POL | DWC_CFGL_HS_SRC_POL); |
4aa5f3664 avr32: at32ap700x... |
2050 2051 |
dws->src_master = 0; dws->dst_master = 1; |
1c5b0538c avr32: at32ap700x... |
2052 2053 2054 |
dws->src_msize = DW_DMA_MSIZE_1; dws->dst_msize = DW_DMA_MSIZE_1; dws->fc = DW_DMA_FC_D_M2P; |
6b0c93514 avr32: at32ap700x... |
2055 2056 2057 2058 |
if (platform_device_add_data(pdev, data, sizeof(struct atmel_abdac_pdata))) goto out_free_resources; |
2042c1c4e [AVR32] Implement... |
2059 |
|
caf18f19e avr32: Allow sele... |
2060 2061 2062 2063 |
pin_mask = (1 << 20) | (1 << 22); /* DATA1 & DATAN1 */ pin_mask |= (1 << 21) | (1 << 23); /* DATA0 & DATAN0 */ select_peripheral(PIOB, pin_mask, PERIPH_A, 0); |
2042c1c4e [AVR32] Implement... |
2064 2065 2066 2067 2068 2069 |
abdac0_pclk.dev = &pdev->dev; abdac0_sample_clk.dev = &pdev->dev; platform_device_add(pdev); return pdev; |
6b0c93514 avr32: at32ap700x... |
2070 |
out_free_resources: |
2042c1c4e [AVR32] Implement... |
2071 2072 2073 2074 2075 |
platform_device_put(pdev); return NULL; } /* -------------------------------------------------------------------- |
7a5fe2387 [AVR32] Make sure... |
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 |
* GCLK * -------------------------------------------------------------------- */ static struct clk gclk0 = { .name = "gclk0", .mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 0, }; static struct clk gclk1 = { .name = "gclk1", .mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 1, }; static struct clk gclk2 = { .name = "gclk2", .mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 2, }; static struct clk gclk3 = { .name = "gclk3", .mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 3, }; static struct clk gclk4 = { .name = "gclk4", .mode = genclk_mode, .get_rate = genclk_get_rate, .set_rate = genclk_set_rate, .set_parent = genclk_set_parent, .index = 4, }; |
300bb7625 avr32: Replace st... |
2118 |
static __initdata struct clk *init_clocks[] = { |
5f97f7f94 [PATCH] avr32 arc... |
2119 2120 2121 2122 2123 2124 2125 2126 2127 |
&osc32k, &osc0, &osc1, &pll0, &pll1, &cpu_clk, &hsb_clk, &pba_clk, &pbb_clk, |
7a5b80590 [AVR32] Split SM ... |
2128 |
&at32_pm_pclk, |
5f97f7f94 [PATCH] avr32 arc... |
2129 |
&at32_intc0_pclk, |
b47eb4092 avr32: Clean up H... |
2130 |
&at32_hmatrix_clk, |
5f97f7f94 [PATCH] avr32 arc... |
2131 2132 |
&ebi_clk, &hramc_clk, |
7951f188a avr32: Enable SDR... |
2133 |
&sdramc_clk, |
bc157b759 [PATCH] AVR32 MTD... |
2134 2135 |
&smc0_pclk, &smc0_mck, |
5f97f7f94 [PATCH] avr32 arc... |
2136 2137 |
&pdc_hclk, &pdc_pclk, |
3bfb1d20b dmaengine: Driver... |
2138 |
&dw_dmac0_hclk, |
5f97f7f94 [PATCH] avr32 arc... |
2139 2140 2141 2142 2143 |
&pico_clk, &pio0_mck, &pio1_mck, &pio2_mck, &pio3_mck, |
7f9f46786 [AVR32] Add PIOE ... |
2144 |
&pio4_mck, |
e723ff666 avr32: Generic cl... |
2145 2146 |
&at32_tcb0_t0_clk, &at32_tcb1_t0_clk, |
d86d314f6 avr32: Add PSIF p... |
2147 2148 |
&atmel_psif0_pclk, &atmel_psif1_pclk, |
1e8ea8021 [PATCH] at91_seri... |
2149 2150 2151 2152 |
&atmel_usart0_usart, &atmel_usart1_usart, &atmel_usart2_usart, &atmel_usart3_usart, |
9a1e8eb1f Basic PWM driver ... |
2153 |
&atmel_pwm0_mck, |
438ff3f3c [AVR32] Add suppo... |
2154 |
#if defined(CONFIG_CPU_AT32AP7000) |
5f97f7f94 [PATCH] avr32 arc... |
2155 2156 |
&macb0_hclk, &macb0_pclk, |
cfcb3a89d [AVR32] Add macb1... |
2157 2158 |
&macb1_hclk, &macb1_pclk, |
438ff3f3c [AVR32] Add suppo... |
2159 |
#endif |
3d60ee1b0 [AVR32] SPI platf... |
2160 2161 |
&atmel_spi0_spi_clk, &atmel_spi1_spi_clk, |
2042c1c4e [AVR32] Implement... |
2162 2163 |
&atmel_twi0_pclk, &atmel_mci0_pclk, |
438ff3f3c [AVR32] Add suppo... |
2164 |
#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002) |
d0a2b7af2 [AVR32] Implement... |
2165 2166 |
&atmel_lcdfb0_hck1, &atmel_lcdfb0_pixclk, |
438ff3f3c [AVR32] Add suppo... |
2167 |
#endif |
9cf6cf58d [AVR32] Add Atmel... |
2168 2169 2170 |
&ssc0_pclk, &ssc1_pclk, &ssc2_pclk, |
6fcf06151 [AVR32] Wire up U... |
2171 2172 |
&usba0_hclk, &usba0_pclk, |
2042c1c4e [AVR32] Implement... |
2173 2174 2175 |
&atmel_ac97c0_pclk, &abdac0_pclk, &abdac0_sample_clk, |
7a5fe2387 [AVR32] Make sure... |
2176 2177 2178 2179 2180 |
&gclk0, &gclk1, &gclk2, &gclk3, &gclk4, |
5f97f7f94 [PATCH] avr32 arc... |
2181 |
}; |
5f97f7f94 [PATCH] avr32 arc... |
2182 |
|
65033ed74 avr32: Move setup... |
2183 |
void __init setup_platform(void) |
5f97f7f94 [PATCH] avr32 arc... |
2184 |
{ |
5f97f7f94 [PATCH] avr32 arc... |
2185 2186 |
u32 cpu_mask = 0, hsb_mask = 0, pba_mask = 0, pbb_mask = 0; int i; |
9e58e1855 [AVR32] CPU frequ... |
2187 |
if (pm_readl(MCCTRL) & PM_BIT(PLLSEL)) { |
5f97f7f94 [PATCH] avr32 arc... |
2188 |
main_clock = &pll0; |
9e58e1855 [AVR32] CPU frequ... |
2189 2190 |
cpu_clk.parent = &pll0; } else { |
5f97f7f94 [PATCH] avr32 arc... |
2191 |
main_clock = &osc0; |
9e58e1855 [AVR32] CPU frequ... |
2192 2193 |
cpu_clk.parent = &osc0; } |
5f97f7f94 [PATCH] avr32 arc... |
2194 |
|
7a5b80590 [AVR32] Split SM ... |
2195 |
if (pm_readl(PLL0) & PM_BIT(PLLOSC)) |
5f97f7f94 [PATCH] avr32 arc... |
2196 |
pll0.parent = &osc1; |
7a5b80590 [AVR32] Split SM ... |
2197 |
if (pm_readl(PLL1) & PM_BIT(PLLOSC)) |
5f97f7f94 [PATCH] avr32 arc... |
2198 |
pll1.parent = &osc1; |
7a5fe2387 [AVR32] Make sure... |
2199 2200 2201 2202 2203 |
genclk_init_parent(&gclk0); genclk_init_parent(&gclk1); genclk_init_parent(&gclk2); genclk_init_parent(&gclk3); genclk_init_parent(&gclk4); |
438ff3f3c [AVR32] Add suppo... |
2204 |
#if defined(CONFIG_CPU_AT32AP7000) || defined(CONFIG_CPU_AT32AP7002) |
d0a2b7af2 [AVR32] Implement... |
2205 |
genclk_init_parent(&atmel_lcdfb0_pixclk); |
438ff3f3c [AVR32] Add suppo... |
2206 |
#endif |
2042c1c4e [AVR32] Implement... |
2207 |
genclk_init_parent(&abdac0_sample_clk); |
7a5fe2387 [AVR32] Make sure... |
2208 |
|
5f97f7f94 [PATCH] avr32 arc... |
2209 |
/* |
300bb7625 avr32: Replace st... |
2210 2211 2212 2213 2214 2215 2216 |
* Build initial dynamic clock list by registering all clocks * from the array. * At the same time, turn on all clocks that have at least one * user already, and turn off everything else. We only do this * for module clocks, and even though it isn't particularly * pretty to check the address of the mode function, it should * do the trick... |
5f97f7f94 [PATCH] avr32 arc... |
2217 |
*/ |
300bb7625 avr32: Replace st... |
2218 2219 2220 2221 2222 |
for (i = 0; i < ARRAY_SIZE(init_clocks); i++) { struct clk *clk = init_clocks[i]; /* first, register clock */ at32_clk_register(clk); |
5f97f7f94 [PATCH] avr32 arc... |
2223 |
|
188ff65d4 [AVR32] Don't ena... |
2224 2225 |
if (clk->users == 0) continue; |
5f97f7f94 [PATCH] avr32 arc... |
2226 2227 2228 2229 2230 2231 2232 2233 2234 |
if (clk->mode == &cpu_clk_mode) cpu_mask |= 1 << clk->index; else if (clk->mode == &hsb_clk_mode) hsb_mask |= 1 << clk->index; else if (clk->mode == &pba_clk_mode) pba_mask |= 1 << clk->index; else if (clk->mode == &pbb_clk_mode) pbb_mask |= 1 << clk->index; } |
7a5b80590 [AVR32] Split SM ... |
2235 2236 2237 2238 |
pm_writel(CPU_MASK, cpu_mask); pm_writel(HSB_MASK, hsb_mask); pm_writel(PBA_MASK, pba_mask); pm_writel(PBB_MASK, pbb_mask); |
65033ed74 avr32: Move setup... |
2239 2240 2241 2242 2243 2244 2245 |
/* Initialize the port muxes */ at32_init_pio(&pio0_device); at32_init_pio(&pio1_device); at32_init_pio(&pio2_device); at32_init_pio(&pio3_device); at32_init_pio(&pio4_device); |
5f97f7f94 [PATCH] avr32 arc... |
2246 |
} |
b83d6ee17 avr32: Add simple... |
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 |
struct gen_pool *sram_pool; static int __init sram_init(void) { struct gen_pool *pool; /* 1KiB granularity */ pool = gen_pool_create(10, -1); if (!pool) goto fail; if (gen_pool_add(pool, 0x24000000, 0x8000, -1)) goto err_pool_add; sram_pool = pool; return 0; err_pool_add: gen_pool_destroy(pool); fail: pr_err("Failed to create SRAM pool "); return -ENOMEM; } core_initcall(sram_init); |