1 |
9d397dfb
|
henryk
|
/* PLL routines for OpenPICC
|
2 |
|
|
* (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
|
3 |
|
|
*
|
4 |
|
|
* This program is free software; you can redistribute it and/or modify
|
5 |
|
|
* it under the terms of the GNU General Public License as published by
|
6 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
7 |
|
|
* (at your option) any later version.
|
8 |
|
|
*
|
9 |
|
|
* This program is distributed in the hope that it will be useful,
|
10 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 |
|
|
* GNU General Public License for more details.
|
13 |
|
|
*
|
14 |
|
|
* You should have received a copy of the GNU General Public License
|
15 |
|
|
* along with this program; if not, write to the Free Software
|
16 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17 |
|
|
*
|
18 |
|
|
*/
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
#include <sys/types.h>
|
22 |
|
|
#include <lib_AT91SAM7.h>
|
23 |
a72e0c20
|
henryk
|
#include "pll.h"
|
24 |
9d397dfb
|
henryk
|
#include "pio_irq.h"
|
25 |
|
|
#include "dbgu.h"
|
26 |
|
|
#include "led.h"
|
27 |
|
|
#include "board.h"
|
28 |
|
|
|
29 |
|
|
void pll_inhibit(int inhibit)
|
30 |
|
|
{
|
31 |
|
|
if (inhibit)
|
32 |
|
|
AT91F_PIO_SetOutput(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_INHIBIT);
|
33 |
|
|
else
|
34 |
|
|
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_INHIBIT);
|
35 |
|
|
}
|
36 |
|
|
|
37 |
f0c0bc64
|
henryk
|
int pll_is_inhibited(void)
|
38 |
|
|
{
|
39 |
|
|
return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_INHIBIT);
|
40 |
|
|
}
|
41 |
|
|
|
42 |
9d397dfb
|
henryk
|
int pll_is_locked(void)
|
43 |
|
|
{
|
44 |
a72e0c20
|
henryk
|
return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC->PLL_LOCK);
|
45 |
9d397dfb
|
henryk
|
}
|
46 |
|
|
|
47 |
b5be7c18
|
henryk
|
static portBASE_TYPE pll_lock_change_cb(u_int32_t pio, portBASE_TYPE xTaskWoken)
|
48 |
9d397dfb
|
henryk
|
{
|
49 |
|
|
(void)pio;
|
50 |
|
|
DEBUGPCRF("PLL LOCK: %d", pll_is_locked());
|
51 |
5cc0ed49
|
henryk
|
#if 0
|
52 |
9d397dfb
|
henryk
|
vLedSetRed(pll_is_locked());
|
53 |
|
|
#endif
|
54 |
b5be7c18
|
henryk
|
return xTaskWoken;
|
55 |
9d397dfb
|
henryk
|
}
|
56 |
|
|
|
57 |
|
|
void pll_init(void)
|
58 |
|
|
{
|
59 |
|
|
AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_INHIBIT);
|
60 |
a72e0c20
|
henryk
|
AT91F_PIO_CfgInput(AT91C_BASE_PIOA, OPENPICC->PLL_LOCK);
|
61 |
9d397dfb
|
henryk
|
pll_inhibit(0);
|
62 |
|
|
|
63 |
a72e0c20
|
henryk
|
pio_irq_register(OPENPICC->PLL_LOCK, &pll_lock_change_cb);
|
64 |
|
|
pio_irq_enable(OPENPICC->PLL_LOCK);
|
65 |
9d397dfb
|
henryk
|
}
|