Changeset 4c754f6 in mainline
- Timestamp:
- 2013-02-11T22:55:29Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f66886
- Parents:
- 40762c6
- Location:
- kernel
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mach/beaglebone/beaglebone.c
r40762c6 r4c754f6 1 1 /* 2 2 * Copyright (c) 2012 Matteo Facchinetti 3 * Copyright (c) 2012 Maurizio Lombardi 3 4 * All rights reserved. 4 5 * … … 38 39 #include <genarch/drivers/am335x/uart.h> 39 40 #include <genarch/drivers/am335x/timer.h> 41 #include <genarch/drivers/am335x/cm_per.h> 42 #include <genarch/drivers/am335x/cm_dpll.h> 43 #include <genarch/drivers/am335x/ctrl_module.h> 40 44 #include <genarch/srln/srln.h> 41 45 #include <interrupt.h> … … 60 64 static struct beaglebone { 61 65 am335x_irc_regs_t *irc_addr; 66 am335x_cm_per_regs_t *cm_per_addr; 67 am335x_cm_dpll_regs_t *cm_dpll_addr; 68 am335x_ctrl_module_t *ctrl_module; 62 69 am335x_timer_t timer; 63 70 am335x_uart_t uart; … … 79 86 static void bbone_init(void) 80 87 { 81 /* Initialize the interrupt controller */82 88 bbone.irc_addr = (void *) km_map(AM335x_IRC_BASE_ADDRESS, 83 89 AM335x_IRC_SIZE, PAGE_NOT_CACHEABLE); 84 90 91 bbone.cm_per_addr = (void *) km_map(AM335x_CM_PER_BASE_ADDRESS, 92 AM335x_CM_PER_SIZE, PAGE_NOT_CACHEABLE); 93 94 bbone.cm_dpll_addr = (void *) km_map(AM335x_CM_DPLL_BASE_ADDRESS, 95 AM335x_CM_DPLL_SIZE, PAGE_NOT_CACHEABLE); 96 97 bbone.ctrl_module = (void *) km_map(AM335x_CTRL_MODULE_BASE_ADDRESS, 98 AM335x_CTRL_MODULE_SIZE, PAGE_NOT_CACHEABLE); 99 100 /* Initialize the interrupt controller */ 85 101 am335x_irc_init(bbone.irc_addr); 86 102 } … … 105 121 irq_initialize(&timer_irq); 106 122 timer_irq.devno = device_assign_devno(); 107 timer_irq.inr = AM335x_DMTIMER 0_IRQ;123 timer_irq.inr = AM335x_DMTIMER2_IRQ; 108 124 timer_irq.claim = bbone_timer_irq_claim; 109 125 timer_irq.handler = bbone_timer_irq_handler; 110 126 irq_register(&timer_irq); 111 127 112 /* Initialize the DMTIMER0 */ 113 am335x_timer_init(&bbone.timer, DMTIMER0, HZ); 128 /* Enable the DMTIMER2 clock module */ 129 am335x_clock_module_enable(bbone.cm_per_addr, DMTIMER2); 130 /* Select the SYSCLK as the clock source for the dmtimer2 module */ 131 am335x_clock_source_select(bbone.cm_dpll_addr, DMTIMER2, 132 CLK_SRC_M_OSC); 133 /* Initialize the DMTIMER2 */ 134 am335x_timer_init(&bbone.timer, DMTIMER2, HZ, 135 am335x_ctrl_module_clock_freq_get(bbone.ctrl_module)); 114 136 /* Enable the interrupt */ 115 am335x_irc_enable(bbone.irc_addr, AM335x_DMTIMER 0_IRQ);137 am335x_irc_enable(bbone.irc_addr, AM335x_DMTIMER2_IRQ); 116 138 /* Start the timer */ 117 139 am335x_timer_start(&bbone.timer); -
kernel/genarch/include/drivers/am335x/cm_dpll.h
r40762c6 r4c754f6 37 37 #define _KERN_AM335X_CM_DPLL_H_ 38 38 39 #include <drivers/am335x/cm_dpll_regs.h> 39 #include "cm_dpll_regs.h" 40 #include "timer.h" 40 41 41 42 #define AM335x_CM_DPLL_BASE_ADDRESS 0x44E00500 42 43 #define AM335x_CM_DPLL_SIZE 256 44 45 static ioport32_t *am335x_cm_dpll_timer_reg_get(am335x_cm_dpll_regs_t *cm, 46 am335x_timer_id_t id) 47 { 48 switch (id) { 49 default: 50 return NULL; 51 case DMTIMER2: 52 return &cm->clksel_timer2; 53 case DMTIMER3: 54 return &cm->clksel_timer3; 55 case DMTIMER4: 56 return &cm->clksel_timer4; 57 case DMTIMER5: 58 return &cm->clksel_timer5; 59 case DMTIMER6: 60 return &cm->clksel_timer6; 61 case DMTIMER7: 62 return &cm->clksel_timer7; 63 } 64 } 65 66 static void am335x_clock_source_select(am335x_cm_dpll_regs_t *cm, 67 am335x_timer_id_t id, am335x_clk_src_t src) 68 { 69 ioport32_t *reg = am335x_cm_dpll_timer_reg_get(cm, id); 70 if (!reg) 71 return; 72 73 *reg = (*reg & ~0x03) | src; 74 } 43 75 44 76 #endif -
kernel/genarch/include/drivers/am335x/cm_dpll_regs.h
r40762c6 r4c754f6 37 37 #define _KERN_AM335X_CM_DPLL_REGS_H_ 38 38 39 #define AM335x_CM_CLKSEL_TIMERS_CLK32KHZ 0x02 40 #define AM335x_CM_CLKSEL_TIMERS_CLKMOSC 0x01 41 #define AM335x_CM_CLKSEL_TIMERS_TCLKIN 0x00 39 typedef enum { 40 CLK_SRC_TCLKIN = 0x00, 41 CLK_SRC_M_OSC, 42 CLK_SRC_32_KHZ 43 } am335x_clk_src_t; 42 44 43 45 typedef struct am335x_cm_dpll_regs { … … 76 78 ioport32_t clksel_gpio0_db; 77 79 78 79 80 } am335x_cm_dpll_regs_t; 80 81 -
kernel/genarch/include/drivers/am335x/cm_per_regs.h
r40762c6 r4c754f6 37 37 #define _KERN_AM335X_CM_PER_REGS_H_ 38 38 39 #include <typedefs.h> 40 39 41 typedef struct am335x_cm_per_regs { 40 42 … … 145 147 #define AM335x_CM_PER_MMC0_CLKCTRL_IDLEST_SHIFT 16 146 148 147 ioport32_ elm_clkctrl;149 ioport32_t elm_clkctrl; 148 150 #define AM335x_CM_PER_ELM_CLKCTRL_MODULEMODE_MASK 0x3 149 151 #define AM335x_CM_PER_ELM_CLKCTRL_MODULEMODE_SHIFT 0 … … 406 408 ioport32_t const pad7[2]; 407 409 408 ioport32_t l3_clkstctrl;409 #define AM335x_CM_PER_ L3_CLKSTCTRL_CLKTRCTRL_MASK 0x3410 #define AM335x_CM_PER_ L3_CLKSTCTRL_CLKTRCTRL_SHIFT 0411 #define AM335x_CM_PER_ L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L3_FLAG (1 << 4)412 #define AM335x_CM_PER_ L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L4_FLAG (1 << 5)410 ioport32_t ocpwp_l3_clkstctrl; 411 #define AM335x_CM_PER_OCPWP_L3_CLKSTCTRL_CLKTRCTRL_MASK 0x3 412 #define AM335x_CM_PER_OCPWP_L3_CLKSTCTRL_CLKTRCTRL_SHIFT 0 413 #define AM335x_CM_PER_OCPWP_L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L3_FLAG (1 << 4) 414 #define AM335x_CM_PER_OCPWP_L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L4_FLAG (1 << 5) 413 415 414 416 ioport32_t ocpwp_clkctrl; -
kernel/genarch/include/drivers/am335x/ctrl_module.h
r40762c6 r4c754f6 37 37 #define _KERN_AM335X_CTRL_MODULE_H_ 38 38 39 #include <drivers/am335x/ctrl_module_regs.h> 39 #include <typedefs.h> 40 #include "ctrl_module_regs.h" 40 41 41 42 #define AM335x_CTRL_MODULE_BASE_ADDRESS 0x44E10000 42 43 #define AM335x_CTRL_MODULE_SIZE 131072 /* 128 Kb */ 43 44 44 static unsigned am335x_ctrl_module_clock_freq_get(void *base) 45 typedef ioport32_t am335x_ctrl_module_t; 46 47 static unsigned am335x_ctrl_module_clock_freq_get(am335x_ctrl_module_t *base) 45 48 { 46 unsigned const control_status = AM335x_CTRL_MODULE_REG_ADDR(base,49 unsigned const control_status = *AM335x_CTRL_MODULE_REG_ADDR(base, 47 50 CONTROL_SYSCONFIG); 48 51 unsigned const sysboot1 = (control_status >> 22) & 0x03; 49 52 50 switch (sysboot ) {53 switch (sysboot1) { 51 54 default: 52 55 case 0: -
kernel/genarch/include/drivers/am335x/timer.h
r40762c6 r4c754f6 37 37 #define _KERN_AM335X_TIMER_H_ 38 38 39 #include "timer_regs.h"39 #include <genarch/drivers/am335x/timer_regs.h> 40 40 41 41 #define AM335x_DMTIMER0_BASE_ADDRESS 0x44E05000 … … 86 86 87 87 extern void am335x_timer_init(am335x_timer_t *timer, am335x_timer_id_t id, 88 unsigned hz );88 unsigned hz, unsigned srcclk_hz); 89 89 extern void am335x_timer_intr_ack(am335x_timer_t *timer); 90 90 extern void am335x_timer_reset(am335x_timer_t *timer); -
kernel/genarch/src/drivers/am335x/timer.c
r40762c6 r4c754f6 56 56 57 57 void 58 am335x_timer_init(am335x_timer_t *timer, am335x_timer_id_t id, unsigned hz) 58 am335x_timer_init(am335x_timer_t *timer, am335x_timer_id_t id, unsigned hz, 59 unsigned srcclk_hz) 59 60 { 60 61 uintptr_t base_addr; … … 86 87 regs->tclr |= AM335x_TIMER_TCLR_AR_FLAG; 87 88 88 /* XXX Here we assume that the timer clock source 89 * is running at 32 Khz but this is not always the 90 * case; DMTIMER[2 - 7] can use the internal system 24 Mhz 91 * clock source or an external clock also. 92 */ 93 unsigned const count = 0xFFFFFFFE - 32768 / hz; 89 /* Disable the emulation mode */ 90 regs->tiocp_cfg |= AM335x_TIMER_TIOCPCFG_EMUFREE_FLAG; 91 92 unsigned const count = 0xFFFFFFFE - (srcclk_hz / hz); 94 93 regs->tcrr = count; 95 94 regs->tldr = count;
Note:
See TracChangeset
for help on using the changeset viewer.