1 /* PLL routines for OpenPICC
2 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
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.
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.
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
21 #include <sys/types.h>
22 #include <lib_AT91SAM7.h>
23 #include <os/pio_irq.h>
26 #include "../openpcd.h"
28 void pll_inhibit(int inhibit
)
31 AT91F_PIO_SetOutput(AT91C_BASE_PIOA
, OPENPICC_PIO_PLL_INHIBIT
);
33 AT91F_PIO_ClearOutput(AT91C_BASE_PIOA
, OPENPICC_PIO_PLL_INHIBIT
);
36 int pll_is_locked(void)
38 return AT91F_PIO_IsInputSet(AT91C_BASE_PIOA
, OPENPICC_PIO_PLL_LOCK
);
41 static void pll_lock_change_cb(u_int32_t pio
)
43 DEBUGPCRF("PLL LOCK: %d", pll_is_locked());
54 AT91F_PIO_CfgOutput(AT91C_BASE_PIOA
, OPENPICC_PIO_PLL_INHIBIT
);
55 AT91F_PIO_CfgInput(AT91C_BASE_PIOA
, OPENPICC_PIO_PLL_LOCK
);
58 pio_irq_register(OPENPICC_PIO_PLL_LOCK
, &pll_lock_change_cb
);
59 pio_irq_enable(OPENPICC_PIO_PLL_LOCK
);