Skip to content

Commit

Permalink
software: remove redundant clk_frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed Nov 22, 2011
1 parent 0f65527 commit 028c9f6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions software/bios/main.c
Expand Up @@ -476,7 +476,7 @@ static int test_user_abort()

puts("I: Press Q or ESC to abort boot");
CSR_TIMER0_COUNTER = 0;
CSR_TIMER0_COMPARE = 2*brd_desc->clk_frequency;
CSR_TIMER0_COMPARE = 2*CSR_FREQUENCY;
CSR_TIMER0_CONTROL = TIMER_ENABLE;
while(CSR_TIMER0_CONTROL & TIMER_ENABLE) {
if(readchar_nonblock()) {
Expand Down Expand Up @@ -596,7 +596,7 @@ static void readstr(char *s, int size)
static void ethreset_delay()
{
CSR_TIMER0_COUNTER = 0;
CSR_TIMER0_COMPARE = brd_desc->clk_frequency >> 2;
CSR_TIMER0_COMPARE = CSR_FREQUENCY >> 2;
CSR_TIMER0_CONTROL = TIMER_ENABLE;
while(CSR_TIMER0_CONTROL & TIMER_ENABLE);
}
Expand Down
7 changes: 3 additions & 4 deletions software/demo/memstats.c
@@ -1,6 +1,6 @@
/*
* Milkymist SoC (Software)
* Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
* Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* 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
Expand All @@ -17,9 +17,8 @@

#include <board.h>

#include <hal/brd.h>

#include <hw/fmlmeter.h>
#include <hw/sysctl.h>

static unsigned int last_stb_count;
static unsigned int last_ack_count;
Expand All @@ -41,7 +40,7 @@ void memstats_tick()

unsigned int memstat_occupancy()
{
return last_stb_count/(brd_desc->clk_frequency/100);
return last_stb_count/(CSR_FREQUENCY/100);
}

unsigned int memstat_net_bandwidth()
Expand Down
3 changes: 1 addition & 2 deletions software/include/base/board.h
@@ -1,6 +1,6 @@
/*
* Milkymist SoC (Software)
* Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
* Copyright (C) 2007, 2008, 2009, 2010, 2011 Sebastien Bourdeauducq
*
* 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
Expand All @@ -23,7 +23,6 @@
struct board_desc {
unsigned short int id;
char name[BOARD_NAME_LEN];
unsigned int clk_frequency;
unsigned int ethernet_phyadr;
};

Expand Down
3 changes: 1 addition & 2 deletions software/libbase/board.c
@@ -1,6 +1,6 @@
/*
* Milkymist SoC (Software)
* Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
* Copyright (C) 2007, 2008, 2009, 2011 Sebastien Bourdeauducq
*
* 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
Expand All @@ -25,7 +25,6 @@ static const struct board_desc boards[1] = {
{
.id = 0x4D31, /* M1 */
.name = "Milkymist One",
.clk_frequency = 80000000,
.ethernet_phyadr = 1
},
};
Expand Down
7 changes: 3 additions & 4 deletions software/libhal/time.c
Expand Up @@ -23,7 +23,6 @@
#include <hw/sysctl.h>
#include <hw/interrupts.h>

#include <hal/brd.h>
#include <hal/time.h>

static int sec;
Expand All @@ -33,7 +32,7 @@ void time_init()
unsigned int mask;

CSR_TIMER0_COUNTER = 0;
CSR_TIMER0_COMPARE = brd_desc->clk_frequency;
CSR_TIMER0_COMPARE = CSR_FREQUENCY;
CSR_TIMER0_CONTROL = TIMER_AUTORESTART|TIMER_ENABLE;
irq_ack(IRQ_TIMER0);

Expand Down Expand Up @@ -64,15 +63,15 @@ void time_get(struct timestamp *ts)
irq_setmask(oldmask);

ts->sec = sec2;
ts->usec = counter/(brd_desc->clk_frequency/1000000);
ts->usec = counter/(CSR_FREQUENCY/1000000);

/*
* If the counter is less than half a second, we consider that
* the overflow was already present when we read the counter
* value.
*/
if(pending) {
if(counter < (brd_desc->clk_frequency/2))
if(counter < (CSR_FREQUENCY/2))
ts->sec++;
}
}
Expand Down

0 comments on commit 028c9f6

Please sign in to comment.