2 * Copyright 2007 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
18 // check communication with ethernet PHY chip
21 #include "memory_map.h"
28 #define DELTA_T 12500000 // .125s (10ns per tick)
29 //#define DELTA_T 10000
31 // debugging output on tx pins
32 #define LS_MASK 0xE0000
33 #define LS_1000 0x80000
34 #define LS_100 0x40000
39 #define U2_ETHERTYPE 0xBEEF
42 static volatile int led_link_up_flag = 0;
45 * Called when eth phy state changes (w/ interrupts disabled)
48 link_changed_callback(int speed)
54 led_link_up_flag = 0x2;
59 led_link_up_flag = 0x2;
64 led_link_up_flag = 0x2;
73 //hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
75 putstr("\neth link changed: speed = ");
80 timer_handler(unsigned irq)
82 static int led_counter = 0;
84 hal_set_timeout(DELTA_T); // schedule next timeout
85 output_regs->leds = (led_counter++ & 0x1) | led_link_up_flag;
93 putstr("\n test_phy_comm\n");
95 pic_register_handler(IRQ_TIMER, timer_handler);
96 hal_set_timeout(DELTA_T); // schedule timeout
98 // setup tx gpio bits for GPIOM_FPGA_1 -- fpga debug output
99 //hal_gpio_set_sels(GPIO_TX_BANK, "1111111111111111");
100 //hal_gpio_set_sels(GPIO_RX_BANK, "1111111111111111");
102 ethernet_register_link_changed_callback(link_changed_callback);
104 output_regs->phy_ctrl = 1; /* reset the eth PHY */
105 output_regs->phy_ctrl = 0;