1
|
/* 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
|
#include "pll.h"
|
24
|
#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
|
int pll_is_inhibited(void)
|
38
|
{
|
39
|
return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_INHIBIT);
|
40
|
}
|
41
|
|
42
|
int pll_is_locked(void)
|
43
|
{
|
44
|
return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC->PLL_LOCK);
|
45
|
}
|
46
|
|
47
|
static portBASE_TYPE pll_lock_change_cb(u_int32_t pio, portBASE_TYPE xTaskWoken)
|
48
|
{
|
49
|
(void)pio;
|
50
|
DEBUGPCRF("PLL LOCK: %d", pll_is_locked());
|
51
|
#if 0
|
52
|
vLedSetRed(pll_is_locked());
|
53
|
#endif
|
54
|
return xTaskWoken;
|
55
|
}
|
56
|
|
57
|
void pll_init(void)
|
58
|
{
|
59
|
AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC_PIO_PLL_INHIBIT);
|
60
|
AT91F_PIO_CfgInput(AT91C_BASE_PIOA, OPENPICC->PLL_LOCK);
|
61
|
pll_inhibit(0);
|
62
|
|
63
|
pio_irq_register(OPENPICC->PLL_LOCK, &pll_lock_change_cb);
|
64
|
pio_irq_enable(OPENPICC->PLL_LOCK);
|
65
|
}
|