Changeset dd0c8a0 in mainline for kernel/genarch
- Timestamp:
- 2013-09-29T06:56:33Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a9bd960d
- Parents:
- 3deb0155 (diff), 13be2583 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel/genarch
- Files:
-
- 3 added
- 3 deleted
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/Makefile.inc
r3deb0155 rdd0c8a0 105 105 endif 106 106 107 ifeq ($(CONFIG_ AM335X_UART),y)107 ifeq ($(CONFIG_OMAP_UART),y) 108 108 GENARCH_SOURCES += \ 109 genarch/src/drivers/ am335x/uart.c109 genarch/src/drivers/omap/uart.c 110 110 endif 111 111 … … 113 113 GENARCH_SOURCES += \ 114 114 genarch/src/drivers/am335x/timer.c 115 endif116 117 ifeq ($(CONFIG_AMDM37X_UART),y)118 GENARCH_SOURCES += \119 genarch/src/drivers/amdm37x/uart.c120 115 endif 121 116 -
kernel/genarch/include/genarch/drivers/am335x/irc.h
r3deb0155 rdd0c8a0 38 38 #define KERN_AM335x_IRQC_H_ 39 39 40 #define AM335x_IRC_BASE_ADDRESS 0x4820000041 #define AM335x_IRC_SIZE 409640 #define AM335x_IRC_BASE_ADDRESS 0x48200000 41 #define AM335x_IRC_SIZE 4096 42 42 43 #define AM335x_IRC_IRQ_COUNT 128 43 #define AM335x_IRC_IRQ_COUNT 128 44 #define AM335x_IRC_IRQ_GROUPS_COUNT 4 44 45 45 #include <typedefs.h> 46 #define OMAP_IRC_IRQ_COUNT AM335x_IRC_IRQ_COUNT 47 #define OMAP_IRC_IRQ_GROUPS_COUNT AM335x_IRC_IRQ_GROUPS_COUNT 46 48 47 typedef struct { 48 const ioport32_t revision; 49 #define AM335x_IRC_REV_MASK 0xFF 50 51 const uint8_t padd0[12]; 52 53 /* This register controls the various parameters 54 * of the OCP interface. 55 */ 56 ioport32_t sysconfig; 57 #define AM335x_IRC_SYSCONFIG_AUTOIDLE_FLAG (1 << 0) 58 #define AM335x_IRC_SYSCONFIG_SOFTRESET_FLAG (1 << 1) 59 60 /* This register provides status information about the module */ 61 const ioport32_t sysstatus; 62 #define AM335x_IRC_SYSSTATUS_RESET_DONE_FLAG (1 << 0) 63 64 const uint8_t padd1[40]; 65 66 /* This register supplies the currently active IRQ interrupt number */ 67 ioport32_t sir_irq; 68 #define AM335x_IRC_SIR_IRQ_ACTIVEIRQ_MASK 0x7F 69 #define AM335x_IRC_SIR_IRQ_SPURIOUSIRQFLAG_MASK 0xFFFFFFF8 70 71 /* This register supplies the currently active FIQ interrupt number */ 72 const ioport32_t sir_fiq; 73 #define AM335x_IRC_FIQ_IRQ_ACTIVEFIQ_MASK 0x7F 74 #define AM335x_IRC_FIQ_IRQ_SPURIOUSFIQFLAG_MASK 0xFFFFFFF8 75 76 /* This register contains the new interrupt agreement bits */ 77 ioport32_t control; 78 #define AM335x_IRC_CONTROL_NEWIRQAGR_FLAG (1 << 0) 79 #define AM335x_IRC_CONTROL_NEWFIQAGR_FLAG (1 << 1) 80 81 /* This register controls protection of the other registers. 82 * This register can only be accessed in priviledged mode, regardless 83 * of the current value of the protection bit. 84 */ 85 ioport32_t protection; 86 #define AM335x_IRC_PROTECTION_FLAG (1 << 0) 87 88 /* This register controls the clock auto-idle for the functional 89 * clock and the input synchronizers. 90 */ 91 ioport32_t idle; 92 #define AM335x_IRC_IDLE_FUNCIDLE_FLAG (1 << 0) 93 #define AM335x_IRC_IDLE_TURBO_FLAG (1 << 1) 94 95 const uint8_t padd2[12]; 96 97 /* This register supplies the currently active IRQ priority level */ 98 const ioport32_t irq_priority; 99 #define AM335x_IRC_IRQ_PRIORITY_IRQPRIORITY_MASK 0x7F 100 #define AM335x_IRC_IRQ_PRIORITY_SPURIOUSIRQFLAG_MASK 0xFFFFFFF8 101 102 /* This register supplies the currently active FIQ priority level */ 103 const ioport32_t fiq_priority; 104 #define AM335x_IRC_FIQ_PRIORITY_FIQPRIORITY_MASK 0x7F 105 #define AM335x_IRC_FIQ_PRIORITY_SPURIOUSIRQFLAG_MASK 0xFFFFFFF8 106 107 /* This register sets the priority threshold */ 108 ioport32_t threshold; 109 #define AM335x_IRC_THRESHOLD_PRIORITYTHRESHOLD_MASK 0xFF 110 #define AM335x_IRC_THRESHOLD_PRIORITYTHRESHOLD_ENABLED 0x00 111 #define AM335x_IRC_THRESHOLD_PRIORITYTHRESHOLD_DISABLED 0xFF 112 113 const uint8_t padd[20]; 114 115 struct { 116 /* Raw interrupt input status before masking */ 117 const ioport32_t itr; 118 119 /* Interrupt mask */ 120 ioport32_t mir; 121 122 /* This register is used to clear the interrupt mask bits, 123 * Write 1 clears the mask bit to 0. 124 */ 125 ioport32_t mir_clear; 126 127 /* This register is used to set the interrupt mask bits, 128 * Write 1 sets the mask bit to 1. 129 */ 130 ioport32_t mir_set; 131 132 /* This register is used to set the software interrupt bits, 133 * it is also used to read the current active software 134 * interrupts. 135 * Write 1 sets the software interrups bits to 1. 136 */ 137 ioport32_t isr_set; 138 139 /* This register is used to clear the software interrups bits. 140 * Write 1 clears the software interrupt bits to 0. 141 */ 142 ioport32_t isr_clear; 143 144 /* This register contains the IRQ status after masking. */ 145 const ioport32_t pending_irq; 146 147 /* This register contains the FIQ status after masking. */ 148 const ioport32_t pending_fiq; 149 } interrupts[4]; 150 151 /* These registers contain the priority for the interrups and 152 * the FIQ/IRQ steering. 153 */ 154 ioport32_t ilr[AM335x_IRC_IRQ_COUNT]; 155 /* 0 = Interrupt routed to IRQ, 1 = interrupt routed to FIQ */ 156 #define AM335x_IRC_ILR_FIQNIRQ_FLAG (1 << 0) 157 #define AM335x_IRC_ILR_PRIORITY_MASK 0x3F 158 #define AM335x_IRC_ILR_PRIORITY_SHIFT 2 159 160 } am335x_irc_regs_t; 161 162 static inline void am335x_irc_init(am335x_irc_regs_t *regs) 163 { 164 int i; 165 166 /* Initialization sequence */ 167 168 /* 1 - Program the SYSCONFIG register: if necessary, enable the 169 * autogating by setting the AUTOIDLE bit. 170 */ 171 regs->sysconfig &= ~AM335x_IRC_SYSCONFIG_AUTOIDLE_FLAG; 172 173 /* 2 - Program the IDLE register: if necessary, disable functional 174 * clock autogating or enable synchronizer autogating by setting 175 * the FUNCIDLE bit or the TURBO bit accordingly. 176 */ 177 regs->idle &= ~AM335x_IRC_IDLE_FUNCIDLE_FLAG; 178 regs->idle &= ~AM335x_IRC_IDLE_TURBO_FLAG; 179 180 /* 3 - Program ILRm register for each interrupt line: Assign a 181 * priority level and set the FIQNIRQ bit for an FIQ interrupt 182 * (by default, interrupts are mapped to IRQ and 183 * priority is 0 (highest). 184 */ 185 186 for (i = 0; i < AM335x_IRC_IRQ_COUNT; ++i) 187 regs->ilr[i] = 0; 188 189 /* 4 - Program the MIRn register: Enable interrupts (by default, 190 * all interrupt lines are masked). 191 */ 192 for (i = 0; i < 4; ++i) 193 regs->interrupts[i].mir_set = 0xFFFFFFFF; 194 } 195 196 /** Get the currently active IRQ interrupt number 197 * 198 * @param regs Pointer to the irc memory mapped registers 199 * 200 * @return The active IRQ interrupt number 201 */ 202 static inline unsigned am335x_irc_inum_get(am335x_irc_regs_t *regs) 203 { 204 return regs->sir_irq & AM335x_IRC_SIR_IRQ_ACTIVEIRQ_MASK; 205 } 206 207 /** Reset IRQ output and enable new IRQ generation 208 * 209 * @param regs Pointer to the irc memory mapped registers 210 */ 211 static inline void am335x_irc_irq_ack(am335x_irc_regs_t *regs) 212 { 213 regs->control = AM335x_IRC_CONTROL_NEWIRQAGR_FLAG; 214 } 215 216 /** Reset FIQ output and enable new FIQ generation 217 * 218 * @param regs Pointer to the irc memory mapped registers 219 */ 220 static inline void am335x_irc_fiq_ack(am335x_irc_regs_t *regs) 221 { 222 regs->control = AM335x_IRC_CONTROL_NEWFIQAGR_FLAG; 223 } 224 225 /** Clear an interrupt mask bit 226 * 227 * @param regs Pointer to the irc memory mapped registers 228 * @param inum The interrupt to be enabled 229 */ 230 static inline void am335x_irc_enable(am335x_irc_regs_t *regs, unsigned inum) 231 { 232 ASSERT(inum < AM335x_IRC_IRQ_COUNT); 233 const unsigned set = inum / 32; 234 const unsigned pos = inum % 32; 235 regs->interrupts[set].mir_clear = (1 << pos); 236 } 237 238 /** Set an interrupt mask bit 239 * 240 * @param regs Pointer to the irc memory mapped registers 241 * @param inum The interrupt to be disabled 242 */ 243 static inline void am335x_irc_disable(am335x_irc_regs_t *regs, unsigned inum) 244 { 245 ASSERT(inum < AM335x_IRC_IRQ_COUNT); 246 const unsigned set = inum / 32; 247 const unsigned pos = inum % 32; 248 regs->interrupts[set].mir_set = (1 << pos); 249 } 49 #include <genarch/drivers/omap/irc.h> 250 50 251 51 #endif -
kernel/genarch/include/genarch/drivers/am335x/uart.h
r3deb0155 rdd0c8a0 37 37 #define _KERN_AM335X_UART_H_ 38 38 39 #include "uart_regs.h"39 #include <genarch/drivers/omap/uart.h> 40 40 41 41 #define AM335x_UART0_BASE_ADDRESS 0x44E09000 … … 63 63 #define AM335x_UART5_IRQ 46 64 64 65 typedef struct {66 am335x_uart_regs_t *regs;67 indev_t *indev;68 outdev_t outdev;69 irq_t irq;70 } am335x_uart_t;71 72 #ifdef CONFIG_AM335X_UART73 extern bool am335x_uart_init(am335x_uart_t *uart, inr_t interrupt,74 uintptr_t addr, size_t size);75 76 extern void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev);77 #else78 static bool am335x_uart_init(am335x_uart_t *uart, inr_t interrupt,79 uintptr_t addr, size_t size)80 { return true; }81 82 static void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev) {}83 #endif84 85 65 #endif 86 66 -
kernel/genarch/include/genarch/drivers/amdm37x/gpt.h
r3deb0155 rdd0c8a0 39 39 #include <typedefs.h> 40 40 #include <mm/km.h> 41 #include <time/clock.h> 41 42 42 43 /* AMDM37x TRM p. 2740 */ … … 128 129 #define AMDM37x_GPT_TCLR_CE_FLAG (1 << 6) 129 130 #define AMDM37x_GPT_TCLR_SCPWM (1 << 7) 130 #define AMDM37x_GPT_TCLR_TCM_MASK (0x3) 131 #define AMDM37x_GPT_TCLR_TCM_SHIFT (8) 132 #define AMDM37x_GPT_TCLR_TRG_MASK (0x3) 133 #define AMDM37x_GPT_TCLR_TRG_SHIFT (10) 131 #define AMDM37x_GPT_TCLR_TCM_MASK (0x3 << 8) 132 #define AMDM37x_GPT_TCLR_TCM_NO_CAPTURE (0x0 << 8) 133 #define AMDM37x_GPT_TCLR_TCM_RAISE_CAPTURE (0x1 << 8) 134 #define AMDM37x_GPT_TCLR_TCM_FALL_CAPTURE (0x2 << 8) 135 #define AMDM37x_GPT_TCLR_TCM_BOTH_CAPTURE (0x3 << 8) 136 #define AMDM37x_GPT_TCLR_TRG_MASK (0x3 << 10) 137 #define AMDM37x_GPT_TCLR_TRG_NO (0x0 << 10) 138 #define AMDM37x_GPT_TCLR_TRG_OVERFLOW (0x1 << 10) 139 #define AMDM37x_GPT_TCLR_TRG_OVERMATCH (0x2 << 10) 134 140 #define AMDM37x_GPT_TCLR_PT_FLAG (1 << 12) 135 141 #define AMDM37x_GPT_TCLR_CAPT_MODE_FLAG (1 << 13) … … 209 215 timer->regs = (void*) km_map(ioregs, iosize, PAGE_NOT_CACHEABLE); 210 216 217 /* Reset the timer */ 218 timer->regs->tiocp_cfg |= AMDM37x_GPT_TIOCP_CFG_SOFTRESET_FLAG; 219 220 while (!(timer->regs->tistat & AMDM37x_GPT_TISTAT_RESET_DONE_FLAG)); 221 211 222 /* Set autoreload */ 212 timer->regs->tclr = AMDM37x_GPT_TCLR_AR_FLAG;223 timer->regs->tclr |= AMDM37x_GPT_TCLR_AR_FLAG; 213 224 214 225 timer->special_available = ( … … 216 227 (ioregs == AMDM37x_GPT2_BASE_ADDRESS) || 217 228 (ioregs == AMDM37x_GPT10_BASE_ADDRESS)); 229 /* Select reload value */ 218 230 timer->regs->tldr = 0xffffffff - (32768 / hz) + 1; 231 /* Set current counter value */ 219 232 timer->regs->tccr = 0xffffffff - (32768 / hz) + 1; 233 220 234 if (timer->special_available) { 221 /* Set values foraccording to formula (manual p. 2733) */235 /* Set values according to formula (manual p. 2733) */ 222 236 /* Use temporary variables for easier debugging */ 223 237 const uint32_t tpir = 224 238 ((32768 / hz + 1) * 1000000) - (32768000L * (1000 / hz)); 225 239 const uint32_t tnir = 226 ((32768 / hz) * 1000000) - (32768000 * (1000 / hz));240 ((32768 / hz) * 1000000) - (32768000L * (1000 / hz)); 227 241 timer->regs->tpir = tpir; 228 242 timer->regs->tnir = tnir; … … 241 255 } 242 256 243 static inline voidamdm37x_gpt_irq_ack(amdm37x_gpt_t* timer)257 static inline bool amdm37x_gpt_irq_ack(amdm37x_gpt_t* timer) 244 258 { 245 259 ASSERT(timer); 246 260 ASSERT(timer->regs); 247 261 /* Clear all pending interrupts */ 248 timer->regs->tisr = timer->regs->tisr; 262 const uint32_t tisr = timer->regs->tisr; 263 timer->regs->tisr = tisr; 264 return tisr != 0; 249 265 } 250 266 -
kernel/genarch/include/genarch/drivers/amdm37x/irc.h
r3deb0155 rdd0c8a0 38 38 39 39 /* AMDM37x TRM p. 1079 */ 40 #define AMDM37x_IRC_BASE_ADDRESS 0x4820000041 #define AMDM37x_IRC_SIZE 409640 #define AMDM37x_IRC_BASE_ADDRESS 0x48200000 41 #define AMDM37x_IRC_SIZE 4096 42 42 43 #define AMDM37x_IRC_IRQ_COUNT 96 43 #define AMDM37x_IRC_IRQ_COUNT 96 44 #define AMDM37x_IRC_IRQ_GROUPS_COUNT 3 44 45 45 #include <typedefs.h> 46 #define OMAP_IRC_IRQ_COUNT AMDM37x_IRC_IRQ_COUNT 47 #define OMAP_IRC_IRQ_GROUPS_COUNT AMDM37x_IRC_IRQ_GROUPS_COUNT 46 48 47 typedef struct { 48 const ioport32_t revision; /**< Revision */ 49 #define AMDM37x_IRC_REV_MASK (0xff) 50 51 uint8_t padd0_[12]; 52 53 ioport32_t sysconfig; /**< SYS config */ 54 #define AMDM37x_IRC_SYSCONFIG_AUTOIDLE_FLAG (1 << 0) 55 #define AMDM37x_IRC_SYSCONFIG_SOFTRESET_FLAG (1 << 1) 56 57 const ioport32_t sysstatus; /**< SYS status */ 58 #define AMDM37x_IRC_SYSSTATUS_RESET_DONE_FLAG (1 << 0) 59 60 uint8_t padd1_[40]; 61 62 const ioport32_t sir_irq; /**< Currently active irq number */ 63 #define AMDM37x_IRC_SIR_IRQ_ACTIVEIRQ_MASK (0x7f) 64 #define AMDM37x_IRC_SIR_IRQ_SPURIOUSIRQFLAG_MASK (0xfffffff8) 65 66 const ioport32_t sir_fiq; 67 #define AMDM37x_IRC_SIR_FIQ_ACTIVEIRQ_MASK (0x7f) 68 #define AMDM37x_IRC_SIR_FIQ_SPURIOUSIRQFLAG_MASK (0xfffffff8) 69 70 ioport32_t control; /**< New interrupt agreement. */ 71 #define AMDM37x_IRC_CONTROL_NEWIRQAGR_FLAG (1 << 0) 72 #define AMDM37x_IRC_CONTROL_NEWFIQAGR_FLAG (1 << 1) 73 74 ioport32_t protection; /**< Protect other registers. */ 75 #define AMDM37x_IRC_PROTECTION_PROETCTION_FLAG (1 << 0) 76 77 ioport32_t idle; /**< Idle and autogating */ 78 #define AMDM37x_IRC_IDLE_FUNCIDLE_FLAG (1 << 0) 79 #define AMDM37x_IRC_IDLE_TURBO_FLAG (1 << 1) 80 81 uint8_t padd2_[12]; 82 83 ioport32_t irq_priority; /**< Active IRQ priority */ 84 #define AMDM37x_IRC_IRQ_PRIORITY_IRQPRIORITY_MASK (0x7f) 85 #define AMDM37x_IRC_IRQ_PRIORITY_SPURIOUSIRQFLAG_MASK (0xfffffff8) 86 87 ioport32_t fiq_priority; /**< Active FIQ priority */ 88 #define AMDM37x_IRC_FIQ_PRIORITY_FIQPRIORITY_MASK (0x7f) 89 #define AMDM37x_IRC_FIQ_PRIORITY_SPURIOUSFIQFLAG_MASK (0xfffffff8) 90 91 ioport32_t threshold; /**< Priority threshold */ 92 #define AMDM37x_IRC_THRESHOLD_PRIORITYTHRESHOLD_MASK (0xff) 93 #define AMDM37x_IRC_THRESHOLD_PRIORITYTHRESHOLD_ENABLED (0x00) 94 #define AMDM37x_IRC_THRESHOLD_PRIORITYTHRESHOLD_DISABLED (0xff) 95 96 uint8_t padd3__[20]; 97 98 struct { 99 const ioport32_t itr; /**< Interrupt input status before masking */ 100 ioport32_t mir; /**< Interrupt mask */ 101 ioport32_t mir_clear; /**< Clear mir mask bits */ 102 ioport32_t mir_set; /**< Set mir mask bits */ 103 ioport32_t isr_set; /**< Set software interrupt bits */ 104 ioport32_t isr_clear; /**< Clear software interrupt bits */ 105 const ioport32_t pending_irq; /**< IRQ status after masking */ 106 const ioport32_t pending_fiq; /**< FIQ status after masking */ 107 } interrupts[3]; 108 109 uint8_t padd4_[32]; 110 111 ioport32_t ilr[96]; /**< FIQ/IRQ steering */ 112 #define AMDM37x_IRC_ILR_FIQNIRQ (1 << 0) 113 #define AMDM37x_IRC_ILR_PRIORITY_MASK (0x3f) 114 #define AMDM37x_IRC_ILR_PRIORITY_SHIFT (2) 115 116 } amdm37x_irc_regs_t; 117 118 static inline void amdm37x_irc_dump(amdm37x_irc_regs_t *regs) 119 { 120 #define DUMP_REG(name) \ 121 printf("%s %p(%x).\n", #name, ®s->name, regs->name); 122 123 DUMP_REG(revision); 124 DUMP_REG(sysconfig); 125 DUMP_REG(sysstatus); 126 DUMP_REG(sir_irq); 127 DUMP_REG(sir_fiq); 128 DUMP_REG(control); 129 DUMP_REG(protection); 130 DUMP_REG(idle); 131 DUMP_REG(irq_priority); 132 DUMP_REG(fiq_priority); 133 DUMP_REG(threshold); 134 135 for (int i = 0; i < 3; ++i) { 136 DUMP_REG(interrupts[i].itr); 137 DUMP_REG(interrupts[i].mir); 138 DUMP_REG(interrupts[i].isr_set); 139 DUMP_REG(interrupts[i].pending_irq); 140 DUMP_REG(interrupts[i].pending_fiq); 141 } 142 for (int i = 0; i < AMDM37x_IRC_IRQ_COUNT; ++i) { 143 DUMP_REG(ilr[i]); 144 } 145 146 #undef DUMP_REG 147 } 148 149 static inline void amdm37x_irc_init(amdm37x_irc_regs_t *regs) 150 { 151 /* AMDM37x TRM sec 12.5.1 p. 2425 */ 152 /* Program system config register */ 153 //TODO enable this when you know the meaning 154 //regs->sysconfig |= AMDM37x_IRC_SYSCONFIG_AUTOIDLE_FLAG; 155 156 /* Program idle register */ 157 //TODO enable this when you know the meaning 158 //regs->sysconfig |= AMDM37x_IRC_IDLE_TURBO_FLAG; 159 160 /* Program ilr[m] assign priority, decide fiq */ 161 for (unsigned i = 0; i < AMDM37x_IRC_IRQ_COUNT; ++i) { 162 regs->ilr[i] = 0; /* highest prio(default) route to irq */ 163 } 164 165 /* Disable all interrupts */ 166 regs->interrupts[0].mir_set = 0xffffffff; 167 regs->interrupts[1].mir_set = 0xffffffff; 168 regs->interrupts[2].mir_set = 0xffffffff; 169 } 170 171 static inline unsigned amdm37x_irc_inum_get(amdm37x_irc_regs_t *regs) 172 { 173 return regs->sir_irq & AMDM37x_IRC_SIR_IRQ_ACTIVEIRQ_MASK; 174 } 175 176 static inline void amdm37x_irc_irq_ack(amdm37x_irc_regs_t *regs) 177 { 178 regs->control = AMDM37x_IRC_CONTROL_NEWIRQAGR_FLAG; 179 } 180 181 static inline void amdm37x_irc_fiq_ack(amdm37x_irc_regs_t *regs) 182 { 183 regs->control = AMDM37x_IRC_CONTROL_NEWFIQAGR_FLAG; 184 } 185 186 static inline void amdm37x_irc_enable(amdm37x_irc_regs_t *regs, unsigned inum) 187 { 188 ASSERT(inum < AMDM37x_IRC_IRQ_COUNT); 189 const unsigned set = inum / 32; 190 const unsigned pos = inum % 32; 191 regs->interrupts[set].mir_clear = (1 << pos); 192 } 193 194 static inline void amdm37x_irc_disable(amdm37x_irc_regs_t *regs, unsigned inum) 195 { 196 ASSERT(inum < AMDM37x_IRC_IRQ_COUNT); 197 const unsigned set = inum / 32; 198 const unsigned pos = inum % 32; 199 regs->interrupts[set].mir_set = (1 << pos); 200 } 49 #include <genarch/drivers/omap/irc.h> 201 50 202 51 #endif -
kernel/genarch/include/genarch/drivers/amdm37x/uart.h
r3deb0155 rdd0c8a0 37 37 #define _AMDM37x_UART_H_ 38 38 39 #include "uart_regs.h"39 #include <genarch/drivers/omap/uart.h> 40 40 41 41 /* AMDM37x TRM p. 2950 */ … … 56 56 #define AMDM37x_UART4_IRQ 80 /* AMDM37x TRM p. 2418 */ 57 57 58 typedef struct {59 amdm37x_uart_regs_t *regs;60 indev_t *indev;61 outdev_t outdev;62 irq_t irq;63 } amdm37x_uart_t;64 65 66 bool amdm37x_uart_init(amdm37x_uart_t *, inr_t, uintptr_t, size_t);67 void amdm37x_uart_input_wire(amdm37x_uart_t *, indev_t *);68 69 58 #endif 70 59 -
kernel/genarch/include/genarch/mm/page_pt.h
r3deb0155 rdd0c8a0 58 58 #define PTL3_ENTRIES PTL3_ENTRIES_ARCH 59 59 60 /* Table sizes in each level */ 61 #define PTL0_SIZE PTL0_SIZE_ARCH 62 #define PTL1_SIZE PTL1_SIZE_ARCH 63 #define PTL2_SIZE PTL2_SIZE_ARCH 64 #define PTL3_SIZE PTL3_SIZE_ARCH 60 /* Table sizes in each level (in frames) */ 61 #define PTL0_FRAMES PTL0_FRAMES_ARCH 62 #define PTL1_FRAMES PTL1_FRAMES_ARCH 63 #define PTL2_FRAMES PTL2_FRAMES_ARCH 64 #define PTL3_FRAMES PTL3_FRAMES_ARCH 65 66 /* Table sizes in each level (in bytes) */ 67 #define PTL0_SIZE FRAMES2SIZE(PTL0_FRAMES) 68 #define PTL1_SIZE FRAMES2SIZE(PTL1_FRAMES) 69 #define PTL2_SIZE FRAMES2SIZE(PTL2_FRAMES) 70 #define PTL3_SIZE FRAMES2SIZE(PTL3_FRAMES) 65 71 66 72 /* -
kernel/genarch/src/drivers/am335x/timer.c
r3deb0155 rdd0c8a0 119 119 /* Disable compare mode */ 120 120 tclr &= ~AM335x_TIMER_TCLR_CE_FLAG; 121 /* Enable the prescaler, divisor = 2 */ 122 tclr |= AM335x_TIMER_TCLR_PRE_FLAG; 123 tclr &= ~(AM335x_TIMER_TCLR_PTV_MASK << AM335x_TIMER_TCLR_PTV_SHIFT); 121 124 122 /* Enable auto-reload mode */ 125 123 tclr |= AM335x_TIMER_TCLR_AR_FLAG; -
kernel/genarch/src/drivers/omap/uart.c
r3deb0155 rdd0c8a0 32 32 /** 33 33 * @file 34 * @brief Texas Instruments AM335xon-chip uart serial line driver.34 * @brief Texas Instruments OMAP on-chip uart serial line driver. 35 35 */ 36 36 37 #include <genarch/drivers/ am335x/uart.h>37 #include <genarch/drivers/omap/uart.h> 38 38 #include <ddi/device.h> 39 39 #include <str.h> 40 40 #include <mm/km.h> 41 41 42 static void am335x_uart_txb(am335x_uart_t *uart, uint8_t b)42 static void omap_uart_txb(omap_uart_t *uart, uint8_t b) 43 43 { 44 44 /* Wait for buffer */ 45 while (uart->regs->ssr & AM335x_UART_SSR_TX_FIFO_FULL_FLAG);45 while (uart->regs->ssr & OMAP_UART_SSR_TX_FIFO_FULL_FLAG); 46 46 /* Write to the outgoing fifo */ 47 47 uart->regs->thr = b; 48 48 } 49 49 50 static void am335x_uart_putchar(outdev_t *dev, wchar_t ch)50 static void omap_uart_putchar(outdev_t *dev, wchar_t ch) 51 51 { 52 am335x_uart_t *uart = dev->data;52 omap_uart_t *uart = dev->data; 53 53 if (!ascii_check(ch)) { 54 am335x_uart_txb(uart, U_SPECIAL);54 omap_uart_txb(uart, U_SPECIAL); 55 55 } else { 56 56 if (ch == '\n') 57 am335x_uart_txb(uart, '\r');58 am335x_uart_txb(uart, ch);57 omap_uart_txb(uart, '\r'); 58 omap_uart_txb(uart, ch); 59 59 } 60 60 } 61 61 62 static outdev_operations_t am335x_uart_ops = {62 static outdev_operations_t omap_uart_ops = { 63 63 .redraw = NULL, 64 .write = am335x_uart_putchar,64 .write = omap_uart_putchar, 65 65 }; 66 66 67 static irq_ownership_t am335x_uart_claim(irq_t *irq)67 static irq_ownership_t omap_uart_claim(irq_t *irq) 68 68 { 69 69 return IRQ_ACCEPT; 70 70 } 71 71 72 static void am335x_uart_handler(irq_t *irq)72 static void omap_uart_handler(irq_t *irq) 73 73 { 74 am335x_uart_t *uart = irq->instance;74 omap_uart_t *uart = irq->instance; 75 75 while ((uart->regs->rx_fifo_lvl)) { 76 76 const uint8_t val = uart->regs->rhr; … … 81 81 } 82 82 83 bool am335x_uart_init(84 am335x_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size)83 bool omap_uart_init( 84 omap_uart_t *uart, inr_t interrupt, uintptr_t addr, size_t size) 85 85 { 86 86 ASSERT(uart); … … 90 90 91 91 /* Soft reset the port */ 92 uart->regs->sysc = AM335x_UART_SYSC_SOFTRESET_FLAG;93 while (!(uart->regs->syss & AM335x_UART_SYSS_RESETDONE_FLAG));92 uart->regs->sysc = OMAP_UART_SYSC_SOFTRESET_FLAG; 93 while (!(uart->regs->syss & OMAP_UART_SYSS_RESETDONE_FLAG)); 94 94 95 95 /* Disable the UART module */ 96 uart->regs->mdr1 |= AM335x_UART_MDR_MS_DISABLE;96 uart->regs->mdr1 |= OMAP_UART_MDR_MS_DISABLE; 97 97 98 98 /* Enable access to EFR register */ … … 100 100 101 101 /* Enable access to TCL_TLR register */ 102 const bool enhanced = uart->regs->efr & AM335x_UART_EFR_ENH_FLAG;103 uart->regs->efr |= AM335x_UART_EFR_ENH_FLAG; /* Turn on enh. */102 const bool enhanced = uart->regs->efr & OMAP_UART_EFR_ENH_FLAG; 103 uart->regs->efr |= OMAP_UART_EFR_ENH_FLAG; /* Turn on enh. */ 104 104 uart->regs->lcr = 0x80; /* Config mode A */ 105 105 106 106 /* Set default (val 0) triggers, disable DMA enable FIFOs */ 107 const bool tcl_tlr = uart->regs->mcr & AM335x_UART_MCR_TCR_TLR_FLAG;107 const bool tcl_tlr = uart->regs->mcr & OMAP_UART_MCR_TCR_TLR_FLAG; 108 108 /* Enable access to tcr and tlr registers */ 109 uart->regs->mcr |= AM335x_UART_MCR_TCR_TLR_FLAG;109 uart->regs->mcr |= OMAP_UART_MCR_TCR_TLR_FLAG; 110 110 111 111 /* Enable FIFOs */ 112 uart->regs->fcr = AM335x_UART_FCR_FIFO_EN_FLAG;112 uart->regs->fcr = OMAP_UART_FCR_FIFO_EN_FLAG; 113 113 114 114 /* Enable fine granularity for RX FIFO and set trigger level to 1, 115 115 * TX FIFO, trigger level is irrelevant*/ 116 116 uart->regs->lcr = 0xBF; /* Sets config mode B */ 117 uart->regs->scr = AM335x_UART_SCR_RX_TRIG_GRANU1_FLAG;118 uart->regs->tlr = 1 << AM335x_UART_TLR_RX_FIFO_TRIG_SHIFT;117 uart->regs->scr = OMAP_UART_SCR_RX_TRIG_GRANU1_FLAG; 118 uart->regs->tlr = 1 << OMAP_UART_TLR_RX_FIFO_TRIG_SHIFT; 119 119 120 120 /* Sets config mode A */ … … 122 122 /* Restore tcl_tlr access flag */ 123 123 if (!tcl_tlr) 124 uart->regs->mcr &= ~ AM335x_UART_MCR_TCR_TLR_FLAG;124 uart->regs->mcr &= ~OMAP_UART_MCR_TCR_TLR_FLAG; 125 125 /* Sets config mode B */ 126 126 uart->regs->lcr = 0xBF; … … 132 132 /* Restore enhanced */ 133 133 if (!enhanced) 134 uart->regs->efr &= ~ AM335x_UART_EFR_ENH_FLAG;134 uart->regs->efr &= ~OMAP_UART_EFR_ENH_FLAG; 135 135 136 136 /* Set the DIV_EN bit to 0 */ 137 uart->regs->lcr &= ~ AM335x_UART_LCR_DIV_EN_FLAG;137 uart->regs->lcr &= ~OMAP_UART_LCR_DIV_EN_FLAG; 138 138 /* Set the BREAK_EN bit to 0 */ 139 uart->regs->lcr &= ~ AM335x_UART_LCR_BREAK_EN_FLAG;139 uart->regs->lcr &= ~OMAP_UART_LCR_BREAK_EN_FLAG; 140 140 /* No parity */ 141 uart->regs->lcr &= ~ AM335x_UART_LCR_PARITY_EN_FLAG;141 uart->regs->lcr &= ~OMAP_UART_LCR_PARITY_EN_FLAG; 142 142 /* Stop = 1 bit */ 143 uart->regs->lcr &= ~ AM335x_UART_LCR_NB_STOP_FLAG;143 uart->regs->lcr &= ~OMAP_UART_LCR_NB_STOP_FLAG; 144 144 /* Char length = 8 bits */ 145 uart->regs->lcr |= AM335x_UART_LCR_CHAR_LENGTH_8BITS;145 uart->regs->lcr |= OMAP_UART_LCR_CHAR_LENGTH_8BITS; 146 146 147 147 /* Enable the UART module */ 148 uart->regs->mdr1 &= ( AM335x_UART_MDR_MS_UART16 &149 ~ AM335x_UART_MDR_MS_MASK);148 uart->regs->mdr1 &= (OMAP_UART_MDR_MS_UART16 & 149 ~OMAP_UART_MDR_MS_MASK); 150 150 151 151 /* Disable interrupts */ … … 153 153 154 154 /* Setup outdev */ 155 outdev_initialize(" am335x_uart_dev", &uart->outdev, &am335x_uart_ops);155 outdev_initialize("omap_uart_dev", &uart->outdev, &omap_uart_ops); 156 156 uart->outdev.data = uart; 157 157 … … 160 160 uart->irq.devno = device_assign_devno(); 161 161 uart->irq.inr = interrupt; 162 uart->irq.claim = am335x_uart_claim;163 uart->irq.handler = am335x_uart_handler;162 uart->irq.claim = omap_uart_claim; 163 uart->irq.handler = omap_uart_handler; 164 164 uart->irq.instance = uart; 165 165 … … 167 167 } 168 168 169 void am335x_uart_input_wire(am335x_uart_t *uart, indev_t *indev)169 void omap_uart_input_wire(omap_uart_t *uart, indev_t *indev) 170 170 { 171 171 ASSERT(uart); … … 175 175 irq_register(&uart->irq); 176 176 /* Enable interrupt on receive */ 177 uart->regs->ier |= AM335x_UART_IER_RHR_IRQ_FLAG;177 uart->regs->ier |= OMAP_UART_IER_RHR_IRQ_FLAG; 178 178 } 179 179 -
kernel/genarch/src/mm/as_pt.c
r3deb0155 rdd0c8a0 73 73 pte_t *ptl0_create(unsigned int flags) 74 74 { 75 pte_t *dst_ptl0 = (pte_t *) frame_alloc(PTL0_SIZE, 76 FRAME_LOWMEM | FRAME_KA); 77 size_t table_size = FRAME_SIZE << PTL0_SIZE; 75 pte_t *dst_ptl0 = (pte_t *) 76 PA2KA(frame_alloc(PTL0_FRAMES, FRAME_LOWMEM, PTL0_SIZE - 1)); 78 77 79 78 if (flags & FLAG_AS_KERNEL) 80 memsetb(dst_ptl0, table_size, 0);79 memsetb(dst_ptl0, PTL0_SIZE, 0); 81 80 else { 82 81 /* 83 82 * Copy the kernel address space portion to new PTL0. 84 *85 83 */ 86 84 … … 95 93 &dst_ptl0[PTL0_INDEX(KERNEL_ADDRESS_SPACE_START)]; 96 94 97 memsetb(dst_ptl0, table_size, 0);95 memsetb(dst_ptl0, PTL0_SIZE, 0); 98 96 memcpy((void *) dst, (void *) src, 99 table_size- (src - (uintptr_t) src_ptl0));97 PTL0_SIZE - (src - (uintptr_t) src_ptl0)); 100 98 101 99 mutex_unlock(&AS_KERNEL->lock); … … 114 112 void ptl0_destroy(pte_t *page_table) 115 113 { 116 frame_free((uintptr_t) page_table );114 frame_free((uintptr_t) page_table, PTL0_FRAMES); 117 115 } 118 116 -
kernel/genarch/src/mm/page_pt.c
r3deb0155 rdd0c8a0 82 82 83 83 if (GET_PTL1_FLAGS(ptl0, PTL0_INDEX(page)) & PAGE_NOT_PRESENT) { 84 pte_t *newpt = (pte_t *) frame_alloc(PTL1_SIZE,85 FRAME_LOWMEM | FRAME_KA);86 memsetb(newpt, FRAME_SIZE <<PTL1_SIZE, 0);84 pte_t *newpt = (pte_t *) 85 PA2KA(frame_alloc(PTL1_FRAMES, FRAME_LOWMEM, PTL1_SIZE - 1)); 86 memsetb(newpt, PTL1_SIZE, 0); 87 87 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(page), KA2PA(newpt)); 88 88 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(page), … … 101 101 102 102 if (GET_PTL2_FLAGS(ptl1, PTL1_INDEX(page)) & PAGE_NOT_PRESENT) { 103 pte_t *newpt = (pte_t *) frame_alloc(PTL2_SIZE,104 FRAME_LOWMEM | FRAME_KA);105 memsetb(newpt, FRAME_SIZE <<PTL2_SIZE, 0);103 pte_t *newpt = (pte_t *) 104 PA2KA(frame_alloc(PTL2_FRAMES, FRAME_LOWMEM, PTL2_SIZE - 1)); 105 memsetb(newpt, PTL2_SIZE, 0); 106 106 SET_PTL2_ADDRESS(ptl1, PTL1_INDEX(page), KA2PA(newpt)); 107 107 SET_PTL2_FLAGS(ptl1, PTL1_INDEX(page), … … 112 112 */ 113 113 write_barrier(); 114 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); 114 SET_PTL2_PRESENT(ptl1, PTL1_INDEX(page)); 115 115 } 116 116 … … 118 118 119 119 if (GET_PTL3_FLAGS(ptl2, PTL2_INDEX(page)) & PAGE_NOT_PRESENT) { 120 pte_t *newpt = (pte_t *) frame_alloc(PTL3_SIZE,121 FRAME_LOWMEM | FRAME_KA);122 memsetb(newpt, FRAME_SIZE << PTL3_SIZE, 0);120 pte_t *newpt = (pte_t *) 121 PA2KA(frame_alloc(PTL3_FRAMES, FRAME_LOWMEM, PTL2_SIZE - 1)); 122 memsetb(newpt, PTL2_SIZE, 0); 123 123 SET_PTL3_ADDRESS(ptl2, PTL2_INDEX(page), KA2PA(newpt)); 124 124 SET_PTL3_FLAGS(ptl2, PTL2_INDEX(page), … … 180 180 * Destroy the mapping. 181 181 * Setting to PAGE_NOT_PRESENT is not sufficient. 182 */ 182 * But we need SET_FRAME for possible PT coherence maintenance. 183 * At least on ARM. 184 */ 185 //TODO: Fix this inconsistency 186 SET_FRAME_FLAGS(ptl3, PTL3_INDEX(page), PAGE_NOT_PRESENT); 183 187 memsetb(&ptl3[PTL3_INDEX(page)], sizeof(pte_t), 0); 184 188 … … 215 219 memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 216 220 #endif 217 frame_free(KA2PA((uintptr_t) ptl3) );221 frame_free(KA2PA((uintptr_t) ptl3), PTL3_FRAMES); 218 222 } else { 219 223 /* … … 249 253 memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 250 254 #endif 251 frame_free(KA2PA((uintptr_t) ptl2) );255 frame_free(KA2PA((uintptr_t) ptl2), PTL2_FRAMES); 252 256 } else { 253 257 /* … … 280 284 281 285 memsetb(&ptl0[PTL0_INDEX(page)], sizeof(pte_t), 0); 282 frame_free(KA2PA((uintptr_t) ptl1) );286 frame_free(KA2PA((uintptr_t) ptl1), PTL1_FRAMES); 283 287 } 284 288 #endif /* PTL1_ENTRIES != 0 */ … … 359 363 * @param size Size in bytes defining the range of PTL0 entries that will be 360 364 * altered by this function. 365 * 361 366 */ 362 367 void pt_mapping_make_global(uintptr_t base, size_t size) 363 368 { 369 ASSERT(size > 0); 370 364 371 uintptr_t ptl0 = PA2KA((uintptr_t) AS_KERNEL->genarch.page_table); 365 372 uintptr_t ptl0_step = ptl0_step_get(); 366 size_t order; 367 uintptr_t addr; 368 373 size_t frames; 374 369 375 #if (PTL1_ENTRIES != 0) 370 order = PTL1_SIZE;376 frames = PTL1_FRAMES; 371 377 #elif (PTL2_ENTRIES != 0) 372 order = PTL2_SIZE;378 frames = PTL2_FRAMES; 373 379 #else 374 order = PTL3_SIZE; 375 #endif 376 377 ASSERT(size > 0); 378 379 for (addr = ALIGN_DOWN(base, ptl0_step); addr - 1 < base + size - 1; 380 frames = PTL3_FRAMES; 381 #endif 382 383 for (uintptr_t addr = ALIGN_DOWN(base, ptl0_step); 384 addr - 1 < base + size - 1; 380 385 addr += ptl0_step) { 381 uintptr_t l1; 382 383 l1 = (uintptr_t) frame_alloc(order, FRAME_KA | FRAME_LOWMEM); 384 memsetb((void *) l1, FRAME_SIZE << order, 0); 386 uintptr_t l1 = PA2KA(frame_alloc(frames, FRAME_LOWMEM, 0)); 387 memsetb((void *) l1, FRAMES2SIZE(frames), 0); 385 388 SET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr), KA2PA(l1)); 386 389 SET_PTL1_FLAGS(ptl0, PTL0_INDEX(addr),
Note:
See TracChangeset
for help on using the changeset viewer.