Commit 57cdc67b authored by Tomasz Wlostowski's avatar Tomasz Wlostowski Committed by Grzegorz Daniluk

boards/wr-switch: moved WRS-specific code to wr-switch BSP, migrated gpio-wrs to gen_gpio framework

parent 4708780d
obj-$(CONFIG_TARGET_GENERIC_PHY_8BIT) += boards/generic/board.o
obj-$(CONFIG_TARGET_GENERIC_PHY_16BIT) += boards/generic/board.o
obj-$(CONFIG_TARGET_WR_SWITCH) += boards/wr-switch/main.o
obj-$(CONFIG_TARGET_WR_SWITCH) += boards/wr-switch/main.o boards/wr-switch/gpio-wrs.o boards/wr-switch/ad9516.o
obj-$(CONFIG_TARGET_AFCZ) += boards/afcz/board.o
......@@ -19,7 +19,8 @@
#include "board.h"
#include "dev/syscon.h"
#include "dev/gpio-wrs.h"
#include "dev/gpio.h"
#include "gpio-wrs.h"
#include "rt_ipc.h"
......@@ -214,12 +215,12 @@ int ad9516_init(int scb_version, int ljd_present)
void *spi_base = (void *)BASE_SPI;
gpio_out(GPIO_SYS_CLK_SEL, 0); /* switch to the standby reference clock, since the PLL is off after reset */
gen_gpio_out(&gpio_pin_sys_clk_sel, 0); /* switch to the standby reference clock, since the PLL is off after reset */
/* reset the PLL */
gpio_out(GPIO_PLL_RESET_N, 0);
gen_gpio_out(&gpio_pin_pll_reset_n, 0);
timer_delay(10);
gpio_out(GPIO_PLL_RESET_N, 1);
gen_gpio_out(&gpio_pin_pll_reset_n, 1);
timer_delay(10);
/* Use unidirectional SPI mode */
......@@ -273,9 +274,9 @@ int ad9516_init(int scb_version, int ljd_present)
pp_printf("AD9516 locked.\n");
gpio_out(GPIO_SYS_CLK_SEL, 1); /* switch the system clock to the PLL reference */
gpio_out(GPIO_PERIPH_RESET_N, 0); /* reset all peripherals which use AD9516-provided clocks */
gpio_out(GPIO_PERIPH_RESET_N, 1);
gen_gpio_out(&gpio_pin_sys_clk_sel, 1); /* switch the system clock to the PLL reference */
gen_gpio_out(&gpio_pin_periph_reset_n, 0); /* reset all peripherals which use AD9516-provided clocks */
gen_gpio_out(&gpio_pin_periph_reset_n, 1);
return 0;
}
......
/*
* This work is part of the White Rabbit project
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef __GPIO_WRS_H
#define __GPIO_WRS_H
#include "dev/gpio.h"
extern const struct gpio_pin gpio_pin_sys_clk_sel;
extern const struct gpio_pin gpio_pin_pll_reset_n;
extern const struct gpio_pin gpio_pin_periph_reset_n;
extern const struct gpio_pin gpio_pin_ljd_board_detect;
void wrs_gpio_init(void);
#endif
\ No newline at end of file
......@@ -13,10 +13,10 @@
#include "minipc.h"
#include "revision.h"
#include "system_checks.h"
#include "dev/gpio-wrs.h"
#include "gpio-wrs.h"
int scb_ver = 33; /* SCB version */
int scb_ljd_present = 0; /* LJD presence */
extern struct spll_stats stats;
......@@ -34,16 +34,17 @@ int main(void)
check_reset();
stats.start_cnt++;
_endram = ENDRAM_MAGIC;
wrs_gpio_init();
console_init();
pp_printf("\n");
pp_printf("WR Switch Real Time Subsystem (c) CERN 2011 - 2014\n");
pp_printf("WR Switch Real Time Subsystem (c) CERN 2011 - 2020\n");
pp_printf("Revision: %s, built: %s %s.\n",
build_revision, build_date, build_time);
pp_printf("SCB version: %d. %s\n", scb_ver,(scb_ver>=34)?"10 MHz SMC Output.":"" );
pp_printf("Start counter %d\n", stats.start_cnt);
/* Low-jitter Daughterboard detection */
ljd_present = gpio_in(GPIO_LJD_BOARD_DETECT);
if (ljd_present) {
scb_ljd_present = gen_gpio_in(&gpio_pin_ljd_board_detect);
if (scb_ljd_present) {
pp_printf("\n--- WRS Low jitter board detected. ---\n");
pp_printf("Allow 1 hour of warming up before starting measurements\n");
}
......@@ -54,7 +55,7 @@ int main(void)
/* for sure problem is in calling second time ad9516_init,
* but not only */
}
ad9516_init(scb_ver, ljd_present);
ad9516_init(scb_ver, scb_ljd_present);
rts_init();
rtipc_init();
spll_very_init();
......
/*
* This work is part of the White Rabbit project
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#ifndef __GPIO_H
#define __GPIO_H
#if 0 // fixme - migrate to new GPIO framework
#include <stdint.h>
#include "board.h"
#define GPIO_SYS_CLK_SEL 0
#define GPIO_PLL_RESET_N 1
#define GPIO_PERIPH_RESET_N 3
#define GPIO_LJD_BOARD_DETECT 4
extern int ljd_present;
struct GPIO_WB
{
uint32_t CODR; /*Clear output register*/
uint32_t SODR; /*Set output register*/
uint32_t DDR; /*Data direction register (1 means out)*/
uint32_t PSR; /*Pin state register*/
};
static volatile struct GPIO_WB *__gpio = (volatile struct GPIO_WB *) BASE_GPIO;
static inline void gpio_out(int pin, int val)
{
if(val)
__gpio->SODR = (1<<pin);
else
__gpio->CODR = (1<<pin);
}
static inline void gpio_dir(int pin, int val)
{
if(val)
__gpio->DDR |= (1<<pin);
else
__gpio->DDR &= ~(1<<pin);
}
static inline int gpio_in(int pin)
{
return __gpio->PSR & (1<<pin) ? 1: 0;
}
#endif
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment