]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/arm/at91/at91_pmc.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / arm / at91 / at91_pmc.c
1 /*-
2  * Copyright (c) 2006 M. Warner Losh.  All rights reserved.
3  * Copyright (c) 2010 Greg Ansley.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/kernel.h>
33 #include <sys/malloc.h>
34 #include <sys/module.h>
35 #include <sys/time.h>
36 #include <sys/bus.h>
37 #include <sys/resource.h>
38 #include <sys/rman.h>
39 #include <sys/timetc.h>
40
41 #include <machine/bus.h>
42 #include <machine/cpu.h>
43 #include <machine/cpufunc.h>
44 #include <machine/resource.h>
45 #include <machine/frame.h>
46 #include <machine/intr.h>
47 #include <arm/at91/at91reg.h>
48 #include <arm/at91/at91var.h>
49
50 #include <arm/at91/at91_pmcreg.h>
51 #include <arm/at91/at91_pmcvar.h>
52
53 static struct at91_pmc_softc {
54         bus_space_tag_t         sc_st;
55         bus_space_handle_t      sc_sh;
56         struct resource *mem_res;       /* Memory resource */
57         device_t                dev;
58 } *pmc_softc;
59
60 static uint32_t pllb_init;
61
62 MALLOC_DECLARE(M_PMC);
63 MALLOC_DEFINE(M_PMC, "at91_pmc_clocks", "AT91 PMC Clock descriptors");
64
65 #define AT91_PMC_BASE 0xffffc00
66
67 static void at91_pmc_set_pllb_mode(struct at91_pmc_clock *, int);
68 static void at91_pmc_set_upll_mode(struct at91_pmc_clock *, int);
69 static void at91_pmc_set_sys_mode(struct at91_pmc_clock *, int);
70 static void at91_pmc_set_periph_mode(struct at91_pmc_clock *, int);
71 static void at91_pmc_clock_alias(const char *name, const char *alias);
72
73 static struct at91_pmc_clock slck = {
74         .name = "slck",         /* 32,768 Hz slow clock */
75         .hz = 32768,
76         .refcnt = 1,
77         .id = 0,
78         .primary = 1,
79 };
80
81 /*
82  * NOTE: Clocks for "ordinary peripheral" devices e.g. spi0, udp0, uhp0 etc.
83  * are now created automatically. Only "system" clocks need be defined here.
84  */
85 static struct at91_pmc_clock main_ck = {
86         .name = "main",         /* Main clock */
87         .refcnt = 0,
88         .id = 1,
89         .primary = 1,
90         .pmc_mask = PMC_IER_MOSCS,
91 };
92
93 static struct at91_pmc_clock plla = {
94         .name = "plla",         /* PLLA Clock, used for CPU clocking */
95         .parent = &main_ck,
96         .refcnt = 1,
97         .id = 0,
98         .primary = 1,
99         .pll = 1,
100         .pmc_mask = PMC_IER_LOCKA,
101 };
102
103 static struct at91_pmc_clock pllb = {
104         .name = "pllb",         /* PLLB Clock, used for USB functions */
105         .parent = &main_ck,
106         .refcnt = 0,
107         .id = 0,
108         .primary = 1,
109         .pll = 1,
110         .pmc_mask = PMC_IER_LOCKB,
111         .set_mode = &at91_pmc_set_pllb_mode,
112 };
113
114 /* Used by USB on at91sam9g45 */
115 static struct at91_pmc_clock upll = {
116         .name = "upll",         /* UTMI PLL, used for USB functions on 9G45 family */
117         .parent = &main_ck,
118         .refcnt = 0,
119         .id = 0,
120         .primary = 1,
121         .pll = 1,
122         .pmc_mask = (1 << 6),
123         .set_mode = &at91_pmc_set_upll_mode,
124 };
125
126 static struct at91_pmc_clock udpck = {
127         .name = "udpck",
128         .parent = &pllb,
129         .pmc_mask = PMC_SCER_UDP,
130         .set_mode = at91_pmc_set_sys_mode
131 };
132
133 static struct at91_pmc_clock uhpck = {
134         .name = "uhpck",
135         .parent = &pllb,
136         .pmc_mask = PMC_SCER_UHP,
137         .set_mode = at91_pmc_set_sys_mode
138 };
139
140 static struct at91_pmc_clock mck = {
141         .name = "mck",          /* Master (Peripheral) Clock */
142         .pmc_mask = PMC_IER_MCKRDY,
143         .refcnt = 0,
144 };
145
146 static struct at91_pmc_clock cpu = {
147         .name = "cpu",          /* CPU Clock */
148         .parent = &plla,
149         .pmc_mask = PMC_SCER_PCK,
150         .refcnt = 0,
151 };
152
153 /* "+32" or the automatic peripheral clocks */
154 static struct at91_pmc_clock *clock_list[16+32] = {
155         &slck,
156         &main_ck,
157         &plla,
158         &pllb,
159         &upll,
160         &udpck,
161         &uhpck,
162         &mck,
163         &cpu
164 };
165
166 static inline uint32_t
167 RD4(struct at91_pmc_softc *sc, bus_size_t off)
168 {
169
170         if (sc == NULL) {
171                 uint32_t *p = (uint32_t *)(AT91_BASE + AT91_PMC_BASE + off);
172
173                 return *p;
174         }
175         return (bus_read_4(sc->mem_res, off));
176 }
177
178 static inline void
179 WR4(struct at91_pmc_softc *sc, bus_size_t off, uint32_t val)
180 {
181
182         if (sc == NULL) {
183                 uint32_t *p = (uint32_t *)(AT91_BASE + AT91_PMC_BASE + off);
184
185                 *p = val;
186         } else
187                 bus_write_4(sc->mem_res, off, val);
188 }
189
190 /*
191  * The following is unused currently since we don't ever set the PLLA
192  * frequency of the device.  If we did, we'd have to also pay attention
193  * to the ICPLLA bit in the PMC_PLLICPR register for frequencies lower
194  * than ~600MHz, which the PMC code doesn't do right now.
195  */
196 uint32_t
197 at91_pmc_800mhz_plla_outb(int freq)
198 {
199         uint32_t outa;
200
201         /*
202          * Set OUTA, per the data sheet.  See Table 46-16 titled
203          * PLLA Frequency Regarding ICPLLA and OUTA in the SAM9X25 doc,
204          * Table 46-17 in the SAM9G20 doc, or Table 46-16 in the SAM9G45 doc.
205          * Note: the frequencies overlap by 5MHz, so we add 3 here to
206          * center shoot the transition.
207          */
208
209         freq /= 1000000;                /* MHz */
210         if (freq >= 800)
211                 freq = 800;
212         freq += 3;                      /* Allow for overlap. */
213         outa = 3 - ((freq / 50) & 3);   /* 750 / 50 = 7, see table */
214         return (1 << 29)| (outa << 14);
215 }
216
217 uint32_t
218 at91_pmc_800mhz_pllb_outb(int freq)
219 {
220
221         return (0);
222 }
223
224 void
225 at91_pmc_set_pllb_mode(struct at91_pmc_clock *clk, int on)
226 {
227         struct at91_pmc_softc *sc = pmc_softc;
228         uint32_t value;
229
230         value = on ? pllb_init : 0;
231
232         /*
233          * Only write to the register if the value is changing.  Besides being
234          * good common sense, this works around RM9200 Errata #26 (CKGR_PLL[AB]R
235          * must not be written with the same value currently in the register).
236          */
237         if (RD4(sc, CKGR_PLLBR) != value) {
238                 WR4(sc, CKGR_PLLBR, value);
239                 while (on && (RD4(sc, PMC_SR) & PMC_IER_LOCKB) != PMC_IER_LOCKB)
240                         continue;
241         }
242 }
243
244 static void
245 at91_pmc_set_upll_mode(struct at91_pmc_clock *clk, int on)
246 {
247         struct at91_pmc_softc *sc = pmc_softc;
248         uint32_t value;
249
250         if (on) {
251                 on = PMC_IER_LOCKU;
252                 value = CKGR_UCKR_UPLLEN | CKGR_UCKR_BIASEN;
253         } else
254                 value = 0;
255
256         WR4(sc, CKGR_UCKR, RD4(sc, CKGR_UCKR) | value);
257         while ((RD4(sc, PMC_SR) & PMC_IER_LOCKU) != on)
258                 continue;
259
260         WR4(sc, PMC_USB, PMC_USB_USBDIV(9) | PMC_USB_USBS);
261         WR4(sc, PMC_SCER, PMC_SCER_UHP_SAM9);
262 }
263
264 static void
265 at91_pmc_set_sys_mode(struct at91_pmc_clock *clk, int on)
266 {
267         struct at91_pmc_softc *sc = pmc_softc;
268
269         WR4(sc, on ? PMC_SCER : PMC_SCDR, clk->pmc_mask);
270         if (on)
271                 while ((RD4(sc, PMC_SCSR) & clk->pmc_mask) != clk->pmc_mask)
272                         continue;
273         else
274                 while ((RD4(sc, PMC_SCSR) & clk->pmc_mask) == clk->pmc_mask)
275                         continue;
276 }
277
278 static void
279 at91_pmc_set_periph_mode(struct at91_pmc_clock *clk, int on)
280 {
281         struct at91_pmc_softc *sc = pmc_softc;
282
283         WR4(sc, on ? PMC_PCER : PMC_PCDR, clk->pmc_mask);
284         if (on)
285                 while ((RD4(sc, PMC_PCSR) & clk->pmc_mask) != clk->pmc_mask)
286                         continue;
287         else
288                 while ((RD4(sc, PMC_PCSR) & clk->pmc_mask) == clk->pmc_mask)
289                         continue;
290 }
291
292 struct at91_pmc_clock *
293 at91_pmc_clock_add(const char *name, uint32_t irq,
294     struct at91_pmc_clock *parent)
295 {
296         struct at91_pmc_clock *clk;
297         int i, buflen;
298
299         clk = malloc(sizeof(*clk), M_PMC, M_NOWAIT | M_ZERO);
300         if (clk == NULL)
301                 goto err;
302
303         buflen = strlen(name) + 1;
304         clk->name = malloc(buflen, M_PMC, M_NOWAIT);
305         if (clk->name == NULL)
306                 goto err;
307
308         strlcpy(clk->name, name, buflen);
309         clk->pmc_mask = 1 << irq;
310         clk->set_mode = &at91_pmc_set_periph_mode;
311         if (parent == NULL)
312                 clk->parent = &mck;
313         else
314                 clk->parent = parent;
315
316         for (i = 0; i < sizeof(clock_list) / sizeof(clock_list[0]); i++) {
317                 if (clock_list[i] == NULL) {
318                         clock_list[i] = clk;
319                         return (clk);
320                 }
321         }
322 err:
323         if (clk != NULL) {
324                 if (clk->name != NULL)
325                         free(clk->name, M_PMC);
326                 free(clk, M_PMC);
327         }
328
329         panic("could not allocate pmc clock '%s'", name);
330         return (NULL);
331 }
332
333 static void
334 at91_pmc_clock_alias(const char *name, const char *alias)
335 {
336         struct at91_pmc_clock *clk, *alias_clk;
337
338         clk = at91_pmc_clock_ref(name);
339         if (clk)
340                 alias_clk = at91_pmc_clock_add(alias, 0, clk->parent);
341
342         if (clk && alias_clk) {
343                 alias_clk->hz = clk->hz;
344                 alias_clk->pmc_mask = clk->pmc_mask;
345                 alias_clk->set_mode = clk->set_mode;
346         }
347 }
348
349 struct at91_pmc_clock *
350 at91_pmc_clock_ref(const char *name)
351 {
352         int i;
353
354         for (i = 0; i < sizeof(clock_list) / sizeof(clock_list[0]); i++) {
355                 if (clock_list[i] == NULL)
356                     break;
357                 if (strcmp(name, clock_list[i]->name) == 0)
358                         return (clock_list[i]);
359         }
360
361         return (NULL);
362 }
363
364 void
365 at91_pmc_clock_deref(struct at91_pmc_clock *clk)
366 {
367         if (clk == NULL)
368                 return;
369 }
370
371 void
372 at91_pmc_clock_enable(struct at91_pmc_clock *clk)
373 {
374         if (clk == NULL)
375                 return;
376
377         /* XXX LOCKING? XXX */
378         if (clk->parent)
379                 at91_pmc_clock_enable(clk->parent);
380         if (clk->refcnt++ == 0 && clk->set_mode)
381                 clk->set_mode(clk, 1);
382 }
383
384 void
385 at91_pmc_clock_disable(struct at91_pmc_clock *clk)
386 {
387         if (clk == NULL)
388                 return;
389
390         /* XXX LOCKING? XXX */
391         if (--clk->refcnt == 0 && clk->set_mode)
392                 clk->set_mode(clk, 0);
393         if (clk->parent)
394                 at91_pmc_clock_disable(clk->parent);
395 }
396
397 static int
398 at91_pmc_pll_rate(struct at91_pmc_clock *clk, uint32_t reg)
399 {
400         uint32_t mul, div, freq;
401
402         freq = clk->parent->hz;
403         div = (reg >> clk->pll_div_shift) & clk->pll_div_mask;
404         mul = (reg >> clk->pll_mul_shift) & clk->pll_mul_mask;
405
406 #if 0
407         printf("pll = (%d /  %d) * %d = %d\n",
408             freq, div, mul + 1, (freq/div) * (mul+1));
409 #endif
410
411         if (div != 0 && mul != 0) {
412                 freq /= div;
413                 freq *= mul + 1;
414         } else
415                 freq = 0;
416         clk->hz = freq;
417
418         return (freq);
419 }
420
421 static uint32_t
422 at91_pmc_pll_calc(struct at91_pmc_clock *clk, uint32_t out_freq)
423 {
424         uint32_t i, div = 0, mul = 0, diff = 1 << 30;
425
426         unsigned ret = 0x3e00;
427
428         if (out_freq > clk->pll_max_out)
429                 goto fail;
430
431         for (i = 1; i < 256; i++) {
432                 int32_t diff1;
433                 uint32_t input, mul1;
434
435                 input = clk->parent->hz / i;
436                 if (input < clk->pll_min_in)
437                         break;
438                 if (input > clk->pll_max_in)
439                         continue;
440
441                 mul1 = out_freq / input;
442                 if (mul1 > (clk->pll_mul_mask + 1))
443                         continue;
444                 if (mul1 == 0)
445                         break;
446
447                 diff1 = out_freq - input * mul1;
448                 if (diff1 < 0)
449                         diff1 = -diff1;
450                 if (diff > diff1) {
451                         diff = diff1;
452                         div = i;
453                         mul = mul1;
454                         if (diff == 0)
455                                 break;
456                 }
457         }
458         if (diff > (out_freq >> PMC_PLL_SHIFT_TOL))
459                 goto fail;
460
461         if (clk->set_outb != NULL)
462                 ret |= clk->set_outb(out_freq);
463
464         return (ret |
465                 ((mul - 1) << clk->pll_mul_shift) |
466                 (div << clk->pll_div_shift));
467 fail:
468         return (0);
469 }
470
471 #if !defined(AT91C_MAIN_CLOCK)
472 static const unsigned int at91_main_clock_tbl[] = {
473         3000000, 3276800, 3686400, 3840000, 4000000,
474         4433619, 4915200, 5000000, 5242880, 6000000,
475         6144000, 6400000, 6553600, 7159090, 7372800,
476         7864320, 8000000, 9830400, 10000000, 11059200,
477         12000000, 12288000, 13560000, 14318180, 14745600,
478         16000000, 17344700, 18432000, 20000000
479 };
480 #define MAIN_CLOCK_TBL_LEN      (sizeof(at91_main_clock_tbl) / sizeof(*at91_main_clock_tbl))
481 #endif
482
483 static unsigned int
484 at91_pmc_sense_main_clock(void)
485 {
486 #if !defined(AT91C_MAIN_CLOCK)
487         unsigned int ckgr_val;
488         unsigned int diff, matchdiff, freq;
489         int i;
490
491         ckgr_val = (RD4(NULL, CKGR_MCFR) & CKGR_MCFR_MAINF_MASK) << 11;
492
493         /*
494          * Clocks up to 50MHz can be connected to some models.  If
495          * the frequency is >= 21MHz, assume that the slow clock can
496          * measure it correctly, and that any error can be adequately
497          * compensated for by roudning to the nearest 500Hz.  Users
498          * with fast, or odd-ball clocks will need to set
499          * AT91C_MAIN_CLOCK in the kernel config file.
500          */
501         if (ckgr_val >= 21000000)
502                 return ((ckgr_val + 250) / 500 * 500);
503
504         /*
505          * Try to find the standard frequency that match best.
506          */
507         freq = at91_main_clock_tbl[0];
508         matchdiff = abs(ckgr_val - at91_main_clock_tbl[0]);
509         for (i = 1; i < MAIN_CLOCK_TBL_LEN; i++) {
510                 diff = abs(ckgr_val - at91_main_clock_tbl[i]);
511                 if (diff < matchdiff) {
512                         freq = at91_main_clock_tbl[i];
513                         matchdiff = diff;
514                 }
515         }
516         return (freq);
517 #else
518         return (AT91C_MAIN_CLOCK);
519 #endif
520 }
521
522 void
523 at91_pmc_init_clock(void)
524 {
525         struct at91_pmc_softc *sc = NULL;
526         unsigned int main_clock;
527         uint32_t mckr;
528         uint32_t mdiv;
529
530         main_clock = at91_pmc_sense_main_clock();
531
532         if (at91_is_sam9() || at91_is_sam9xe()) {
533                 uhpck.pmc_mask = PMC_SCER_UHP_SAM9;
534                 udpck.pmc_mask = PMC_SCER_UDP_SAM9;
535         }
536
537         /* There is no pllb on AT91SAM9G45 */
538         if (at91_cpu_is(AT91_T_SAM9G45)) {
539                 uhpck.parent = &upll;
540                 uhpck.pmc_mask = PMC_SCER_UHP_SAM9;
541         }
542
543         mckr = RD4(sc, PMC_MCKR);
544         main_ck.hz = main_clock;
545
546         /*
547          * Note: this means outa calc code for plla never used since
548          * we never change it.  If we did, we'd also have to mind
549          * ICPLLA to get the charge pump current right.
550          */
551         at91_pmc_pll_rate(&plla, RD4(sc, CKGR_PLLAR));
552
553         if (at91_cpu_is(AT91_T_SAM9G45) && (mckr & PMC_MCKR_PLLADIV2))
554                 plla.hz /= 2;
555
556         /*
557          * Initialize the usb clock.  This sets up pllb, but disables the
558          * actual clock. XXX except for the if 0 :(
559          */
560         if (!at91_cpu_is(AT91_T_SAM9G45)) {
561                 pllb_init = at91_pmc_pll_calc(&pllb, 48000000 * 2) | 0x10000000;
562                 at91_pmc_pll_rate(&pllb, pllb_init);
563 #if 0
564                 /* Turn off USB clocks */
565                 at91_pmc_set_periph_mode(&ohci_clk, 0);
566                 at91_pmc_set_periph_mode(&udc_clk, 0);
567 #endif
568         }
569
570         if (at91_is_rm92()) {
571                 WR4(sc, PMC_SCDR, PMC_SCER_UHP | PMC_SCER_UDP);
572                 WR4(sc, PMC_SCER, PMC_SCER_MCKUDP);
573         } else
574                 WR4(sc, PMC_SCDR, PMC_SCER_UHP_SAM9 | PMC_SCER_UDP_SAM9);
575
576         /*
577          * MCK and PCU derive from one of the primary clocks.  Initialize
578          * this relationship.
579          */
580         mck.parent = clock_list[mckr & 0x3];
581         mck.parent->refcnt++;
582
583         cpu.hz = mck.hz = mck.parent->hz /
584             (1 << ((mckr & PMC_MCKR_PRES_MASK) >> 2));
585
586         mdiv = (mckr & PMC_MCKR_MDIV_MASK) >> 8;
587         if (at91_is_sam9() || at91_is_sam9xe()) {
588                 /*
589                  * On AT91SAM9G45 when mdiv == 3 we need to divide
590                  * MCK by 3 but not, for example, on 9g20.
591                  */
592                 if (!at91_cpu_is(AT91_T_SAM9G45) || mdiv <= 2)
593                         mdiv *= 2;
594                 if (mdiv > 0)
595                         mck.hz /= mdiv;
596         } else
597                 mck.hz /= (1 + mdiv);
598
599         /* Only found on SAM9G20 */
600         if (at91_cpu_is(AT91_T_SAM9G20))
601                 cpu.hz /= (mckr & PMC_MCKR_PDIV) ?  2 : 1;
602
603         at91_master_clock = mck.hz;
604
605         /* These clocks refrenced by "special" names */
606         at91_pmc_clock_alias("ohci0", "ohci_clk");
607         at91_pmc_clock_alias("udp0",  "udp_clk");
608
609         /* Turn off "Progamable" clocks */
610         WR4(sc, PMC_SCDR, PMC_SCER_PCK0 | PMC_SCER_PCK1 | PMC_SCER_PCK2 |
611             PMC_SCER_PCK3);
612
613         /* XXX kludge, turn on all peripherals */
614         WR4(sc, PMC_PCER, 0xffffffff);
615
616         /* Disable all interrupts for PMC */
617         WR4(sc, PMC_IDR, 0xffffffff);
618 }
619
620 static void
621 at91_pmc_deactivate(device_t dev)
622 {
623         struct at91_pmc_softc *sc;
624
625         sc = device_get_softc(dev);
626         bus_generic_detach(sc->dev);
627         if (sc->mem_res)
628                 bus_release_resource(dev, SYS_RES_IOPORT,
629                     rman_get_rid(sc->mem_res), sc->mem_res);
630         sc->mem_res = 0;
631 }
632
633 static int
634 at91_pmc_activate(device_t dev)
635 {
636         struct at91_pmc_softc *sc;
637         int rid;
638
639         sc = device_get_softc(dev);
640         rid = 0;
641         sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
642             RF_ACTIVE);
643         if (sc->mem_res == NULL)
644                 goto errout;
645         return (0);
646 errout:
647         at91_pmc_deactivate(dev);
648         return (ENOMEM);
649 }
650
651 static int
652 at91_pmc_probe(device_t dev)
653 {
654
655         device_set_desc(dev, "PMC");
656         return (0);
657 }
658
659 static int
660 at91_pmc_attach(device_t dev)
661 {
662         int err;
663
664         pmc_softc = device_get_softc(dev);
665         pmc_softc->dev = dev;
666         if ((err = at91_pmc_activate(dev)) != 0)
667                 return (err);
668
669         /*
670          * Configure main clock frequency.
671          */
672         at91_pmc_init_clock();
673
674         /*
675          * Display info about clocks previously computed
676          */
677         device_printf(dev,
678             "Primary: %d Hz PLLA: %d MHz CPU: %d MHz MCK: %d MHz\n",
679             main_ck.hz,
680             plla.hz / 1000000,
681             cpu.hz / 1000000, mck.hz / 1000000);
682
683         return (0);
684 }
685
686 static device_method_t at91_pmc_methods[] = {
687         DEVMETHOD(device_probe, at91_pmc_probe),
688         DEVMETHOD(device_attach, at91_pmc_attach),
689         DEVMETHOD_END
690 };
691
692 static driver_t at91_pmc_driver = {
693         "at91_pmc",
694         at91_pmc_methods,
695         sizeof(struct at91_pmc_softc),
696 };
697 static devclass_t at91_pmc_devclass;
698
699 DRIVER_MODULE(at91_pmc, atmelarm, at91_pmc_driver, at91_pmc_devclass, NULL,
700     NULL);