Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0f66886 in mainline


Ignore:
Timestamp:
2013-02-13T20:19:29Z (9 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master
Children:
06c4609
Parents:
4c754f6
Message:

fix sysclock frequency reading and print an error message is the operation was unsuccessful

Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/mach/beaglebone/beaglebone.c

    r4c754f6 r0f66886  
    117117static void bbone_timer_irq_start(void)
    118118{
     119        unsigned sysclk_freq;
     120
    119121        /* Initialize the IRQ */
    120122        static irq_t timer_irq;
     
    132134           CLK_SRC_M_OSC);
    133135        /* Initialize the DMTIMER2 */
    134         am335x_timer_init(&bbone.timer, DMTIMER2, HZ,
    135             am335x_ctrl_module_clock_freq_get(bbone.ctrl_module));
     136        if (am335x_ctrl_module_clock_freq_get(bbone.ctrl_module,
     137            &sysclk_freq) != EOK) {
     138                printf("Cannot get the system clock frequency!\n");
     139                return;
     140        }
     141
     142        am335x_timer_init(&bbone.timer, DMTIMER2, HZ, sysclk_freq);
    136143        /* Enable the interrupt */
    137144        am335x_irc_enable(bbone.irc_addr, AM335x_DMTIMER2_IRQ);
  • kernel/genarch/include/drivers/am335x/ctrl_module.h

    r4c754f6 r0f66886  
    3737#define _KERN_AM335X_CTRL_MODULE_H_
    3838
     39#include <errno.h>
    3940#include <typedefs.h>
    4041#include "ctrl_module_regs.h"
     
    4546typedef ioport32_t am335x_ctrl_module_t;
    4647
    47 static unsigned am335x_ctrl_module_clock_freq_get(am335x_ctrl_module_t *base)
     48static int
     49am335x_ctrl_module_clock_freq_get(am335x_ctrl_module_t *base, unsigned *freq)
    4850{
    4951        unsigned const control_status = *AM335x_CTRL_MODULE_REG_ADDR(base,
    50             CONTROL_SYSCONFIG);
     52            CONTROL_STATUS);
    5153        unsigned const sysboot1 = (control_status >> 22) & 0x03;
    5254
    5355        switch (sysboot1) {
    5456        default:
     57                return EOK;
    5558        case 0:
    56                 return 19200000; /* 19.2 Mhz */
     59                *freq = 19200000; /* 19.2 Mhz */
    5760        case 1:
    58                 return 24000000; /* 24 Mhz */
     61                *freq = 24000000; /* 24 Mhz */
    5962        case 2:
    60                 return 25000000; /* 25 Mhz */
     63                *freq = 25000000; /* 25 Mhz */
    6164        case 3:
    62                 return 26000000; /* 26 Mhz */
     65                *freq = 26000000; /* 26 Mhz */
    6366        }
     67
     68        return EINVAL;
    6469}
    6570
Note: See TracChangeset for help on using the changeset viewer.