source: mainline/kernel/arch/arm32/src/mach/beagleboardxm/beagleboardxm.c@ 05a6548

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 05a6548 was 05a6548, checked in by Jan Vesely <jano.vesely@…>, 14 years ago

beagleboardxm: Initialize and use pic and uart.

Timer is still missing.

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*
2 * Copyright (c) 2012 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/** @addtogroup arm32beagleboardxm
29 * @{
30 */
31/** @file
32 * @brief BeagleBoard-xM platform driver.
33 */
34
35#include <arch/exception.h>
36#include <arch/mach/beagleboardxm/beagleboardxm.h>
37#include <genarch/drivers/amdm37x_irc/amdm37x_irc.h>
38#include <genarch/drivers/amdm37x_uart/amdm37x_uart.h>
39#include <interrupt.h>
40#include <mm/km.h>
41#include <ddi/ddi.h>
42#include <ddi/device.h>
43
44static void bbxm_init(void);
45static void bbxm_timer_irq_start(void);
46static void bbxm_cpu_halt(void);
47static void bbxm_get_memory_extents(uintptr_t *start, size_t *size);
48static void bbxm_irq_exception(unsigned int exc_no, istate_t *istate);
49static void bbxm_frame_init(void);
50static void bbxm_output_init(void);
51static void bbxm_input_init(void);
52static size_t bbxm_get_irq_count(void);
53static const char *bbxm_get_platform_name(void);
54
55static struct beagleboard {
56 amdm37x_irc_regs_t *irc_addr;
57 amdm37x_uart_t uart;
58} beagleboard;
59
60struct arm_machine_ops bbxm_machine_ops = {
61 bbxm_init,
62 bbxm_timer_irq_start,
63 bbxm_cpu_halt,
64 bbxm_get_memory_extents,
65 bbxm_irq_exception,
66 bbxm_frame_init,
67 bbxm_output_init,
68 bbxm_input_init,
69 bbxm_get_irq_count,
70 bbxm_get_platform_name
71};
72
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
89static void bbxm_init(void)
90{
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
98}
99
100static void bbxm_timer_irq_start(void)
101{
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
111}
112
113static void bbxm_cpu_halt(void)
114{
115}
116
117/** Get extents of available memory.
118 *
119 * @param start Place to store memory start address (physical).
120 * @param size Place to store memory size.
121 */
122static void bbxm_get_memory_extents(uintptr_t *start, size_t *size)
123{
124 // FIXME: This is just a guess...
125 *start = 0;
126 *size = 256 * 1024 * 1024;
127}
128
129static void bbxm_irq_exception(unsigned int exc_no, istate_t *istate)
130{
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 }
144}
145
146static void bbxm_frame_init(void)
147{
148}
149
150static void bbxm_output_init(void)
151{
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 }
162}
163
164static void bbxm_input_init(void)
165{
166}
167
168size_t bbxm_get_irq_count(void)
169{
170 return AMDM37x_IRC_IRQ_COUNT;
171}
172
173const char *bbxm_get_platform_name(void)
174{
175 return "beagleboardxm";
176}
177
178/**
179 * @}
180 */
Note: See TracBrowser for help on using the repository browser.