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

Changeset 05a6548 in mainline


Ignore:
Timestamp:
2012-03-04T20:40:19Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
d2707fc
Parents:
e6a356dd
Message:

beagleboardxm: Initialize and use pic and uart.

Timer is still missing.

File:
1 edited

Legend:

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

    re6a356dd r05a6548  
    3030 */
    3131/** @file
    32  *  @brief BeagleBoard platform driver.
     32 *  @brief BeagleBoard-xM platform driver.
    3333 */
    3434
    3535#include <arch/exception.h>
    3636#include <arch/mach/beagleboardxm/beagleboardxm.h>
     37#include <genarch/drivers/amdm37x_irc/amdm37x_irc.h>
     38#include <genarch/drivers/amdm37x_uart/amdm37x_uart.h>
    3739#include <interrupt.h>
     40#include <mm/km.h>
    3841#include <ddi/ddi.h>
    3942#include <ddi/device.h>
     
    5053static const char *bbxm_get_platform_name(void);
    5154
     55static struct beagleboard {
     56        amdm37x_irc_regs_t *irc_addr;
     57        amdm37x_uart_t uart;
     58} beagleboard;
     59
    5260struct arm_machine_ops bbxm_machine_ops = {
    5361        bbxm_init,
     
    6371};
    6472
     73static irq_ownership_t bb_timer_irq_claim(irq_t *irq)
     74{
     75        return IRQ_ACCEPT;
     76}
     77
     78static void bb_timer_irq_handler(irq_t *irq)
     79{
     80        /*
     81         * We are holding a lock which prevents preemption.
     82         * Release the lock, call clock() and reacquire the lock again.
     83         */
     84        spinlock_unlock(&irq->lock);
     85        clock();
     86        spinlock_lock(&irq->lock);
     87}
     88
    6589static void bbxm_init(void)
    6690{
     91        /* Initialize interrupt controller */
     92        beagleboard.irc_addr =
     93            (void *) km_map(AMDM37x_IRC_BASE_ADDRESS, AMDM37x_IRC_SIZE,
     94            PAGE_NOT_CACHEABLE);
     95        amdm37x_irc_init(beagleboard.irc_addr);
     96
     97        //initialize timer here
    6798}
    6899
    69100static void bbxm_timer_irq_start(void)
    70101{
     102        /* Initialize timer IRQ */
     103        static irq_t timer_irq;
     104        irq_initialize(&timer_irq);
     105        timer_irq.devno = device_assign_devno();
     106        timer_irq.inr = 0;//BB_TIMER_IRQ;
     107        timer_irq.claim = bb_timer_irq_claim;
     108        timer_irq.handler = bb_timer_irq_handler;
     109        irq_register(&timer_irq);
     110        // start timer here
    71111}
    72112
     
    82122static void bbxm_get_memory_extents(uintptr_t *start, size_t *size)
    83123{
     124        // FIXME: This is just a guess...
     125        *start = 0;
     126        *size = 256 * 1024 * 1024;
    84127}
    85128
    86129static void bbxm_irq_exception(unsigned int exc_no, istate_t *istate)
    87130{
     131        const unsigned inum = amdm37x_irc_inum_get(beagleboard.irc_addr);
     132        amdm37x_irc_irq_ack(beagleboard.irc_addr);
     133
     134        irq_t *irq = irq_dispatch_and_lock(inum);
     135        if (irq) {
     136                /* The IRQ handler was found. */
     137                irq->handler(irq);
     138                spinlock_unlock(&irq->lock);
     139        } else {
     140                /* Spurious interrupt.*/
     141                printf("cpu%d: spurious interrupt (inum=%d)\n",
     142                    CPU->id, inum);
     143        }
    88144}
    89145
     
    94150static void bbxm_output_init(void)
    95151{
     152#ifdef CONFIG_FB
     153#error "Frame buffer is not yet supported!"
     154#endif
     155
     156        /* UART3 is wired to external RS232 connector */
     157        const bool ok = amdm37x_uart_init(&beagleboard.uart,
     158            AMDM37x_UART3_IRQ, AMDM37x_UART3_BASE_ADDRESS, AMDM37x_UART3_SIZE);
     159        if (ok) {
     160                stdout_wire(&beagleboard.uart.outdev);
     161        }
    96162}
    97163
     
    102168size_t bbxm_get_irq_count(void)
    103169{
    104         return 0;
     170        return AMDM37x_IRC_IRQ_COUNT;
    105171}
    106172
Note: See TracChangeset for help on using the changeset viewer.