From 6304718e371e590b09e176c05df21fc5fb631cec Mon Sep 17 00:00:00 2001 From: henryk Date: Wed, 5 Mar 2008 05:03:36 +0000 Subject: Port over the differential miller decoder from the sniffonly host tool Move clock switch to its own header file Specify default (and for non-clock switching capable hardware: single) clock source in hardware definitions git-svn-id: https://svn.openpcd.org:2342/trunk@443 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpicc/application/clock_switch.c | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 openpicc/application/clock_switch.c (limited to 'openpicc/application/clock_switch.c') diff --git a/openpicc/application/clock_switch.c b/openpicc/application/clock_switch.c new file mode 100644 index 0000000..16c1bf1 --- /dev/null +++ b/openpicc/application/clock_switch.c @@ -0,0 +1,53 @@ +/*************************************************************** + * + * OpenPICC - clock switch driver + * + * Copyright 2008 Henryk Plötz + * + *************************************************************** + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +*/ + +#include +#include + +#include "clock_switch.h" + +static int initialized = 0; + +void clock_switch(enum clock_source clock) +{ + if(!OPENPICC->features.clock_switching) return; + if(!initialized) + AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH); + + switch(clock) { + case CLOCK_SELECT_PLL: + AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH); + break; + case CLOCK_SELECT_CARRIER: + AT91F_PIO_SetOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH); + break; + } +} + +void clock_switch_init(void) +{ + if(!OPENPICC->features.clock_switching) return; + AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC->CLOCK_SWITCH); + clock_switch(OPENPICC->default_clock); + initialized = 1; +} -- cgit v1.2.3