The Pedigree Project  0.1
Beagle.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "Beagle.h"
21 #include "Gpio.h"
22 #include "I2C.h"
23 #include "Prcm.h"
24 
25 #include "pedigree/kernel/machine/Bus.h"
26 #include "pedigree/kernel/machine/Controller.h"
27 #include "pedigree/kernel/machine/Device.h"
28 #include "pedigree/kernel/machine/Disk.h"
29 #include "pedigree/kernel/machine/Pci.h"
30 
31 ArmBeagle ArmBeagle::m_Instance;
32 
33 Machine &Machine::instance()
34 {
35  return ArmBeagle::instance();
36 }
37 
39 {
40  Bus *pL4 = new Bus("L4-Interconnect");
41  pL4->setSpecificType(String("l4"));
42 
43  Controller *pGpio1 = new Controller();
44  pGpio1->setSpecificType(String("gpio"));
45  pGpio1->addresses().pushBack(
46  new Device::Address(String("mmio"), 0x48310000, 0x1000, false));
47  pGpio1->setInterruptNumber(29);
48  pL4->addChild(pGpio1);
49  pGpio1->setParent(pL4);
50 
51  Controller *pGpio2 = new Controller();
52  pGpio2->setSpecificType(String("gpio"));
53  pGpio2->addresses().pushBack(
54  new Device::Address(String("mmio"), 0x49050000, 0x1000, false));
55  pGpio2->setInterruptNumber(30);
56  pL4->addChild(pGpio2);
57  pGpio2->setParent(pL4);
58 
59  Controller *pGpio3 = new Controller();
60  pGpio3->setSpecificType(String("gpio"));
61  pGpio3->addresses().pushBack(
62  new Device::Address(String("mmio"), 0x49052000, 0x1000, false));
63  pGpio3->setInterruptNumber(31);
64  pL4->addChild(pGpio3);
65  pGpio3->setParent(pL4);
66 
67  Controller *pGpio4 = new Controller();
68  pGpio4->setSpecificType(String("gpio"));
69  pGpio4->addresses().pushBack(
70  new Device::Address(String("mmio"), 0x49054000, 0x1000, false));
71  pGpio4->setInterruptNumber(32);
72  pL4->addChild(pGpio4);
73  pGpio4->setParent(pL4);
74 
75  Controller *pGpio5 = new Controller();
76  pGpio5->setSpecificType(String("gpio"));
77  pGpio5->addresses().pushBack(
78  new Device::Address(String("mmio"), 0x49056000, 0x1000, false));
79  pGpio5->setInterruptNumber(33);
80  pL4->addChild(pGpio5);
81  pGpio5->setParent(pL4);
82 
83  Controller *pGpio6 = new Controller();
84  pGpio6->setSpecificType(String("gpio"));
85  pGpio6->addresses().pushBack(
86  new Device::Address(String("mmio"), 0x49058000, 0x1000, false));
87  pGpio6->setInterruptNumber(34);
88  pL4->addChild(pGpio6);
89  pGpio6->setParent(pL4);
90 
91  Controller *pMmc1 = new Controller();
92  pMmc1->setSpecificType(String("mmc_sd_sdio"));
93  pMmc1->addresses().pushBack(
94  new Device::Address(String("mmio"), 0x4809C000, 0x1000, false));
95  pMmc1->setInterruptNumber(83);
96  pL4->addChild(pMmc1);
97  pMmc1->setParent(pL4);
98 
99  Controller *pMmc2 = new Controller();
100  pMmc2->setSpecificType(String("mmc_sd_sdio"));
101  pMmc2->addresses().pushBack(
102  new Device::Address(String("mmio"), 0x480B4000, 0x1000, false));
103  pMmc2->setInterruptNumber(86);
104  pL4->addChild(pMmc2);
105  pMmc2->setParent(pL4);
106 
107  Controller *pMmc3 = new Controller();
108  pMmc3->setSpecificType(String("mmc_sd_sdio"));
109  pMmc3->addresses().pushBack(
110  new Device::Address(String("mmio"), 0x480AD000, 0x1000, false));
111  pMmc3->setInterruptNumber(94);
112  pL4->addChild(pMmc3);
113  pMmc3->setParent(pL4);
114 
115  Controller *pCtl = new Controller();
116  pCtl->setSpecificType(String("display-subsys"));
117  pCtl->addresses().pushBack(new Device::Address(
118  String("DSI Protocol Engine"), 0x4804FC00, 512, false));
119  pCtl->addresses().pushBack(
120  new Device::Address(String("DSI_PHY"), 0x4804FE00, 64, false));
121  pCtl->addresses().pushBack(new Device::Address(
122  String("DSI PLL Controller"), 0x4804FF00, 32, false));
123  pCtl->addresses().pushBack(new Device::Address(
124  String("Display Subsystem"), 0x48050000, 512, false));
125  pCtl->addresses().pushBack(new Device::Address(
126  String("Display Controller"), 0x48050400, 1024, false));
127  pCtl->addresses().pushBack(
128  new Device::Address(String("RFBI"), 0x48050800, 256, false));
129  pCtl->addresses().pushBack(
130  new Device::Address(String("Video Encoder"), 0x48050C00, 256, false));
131  pCtl->setInterruptNumber(25);
132  pL4->addChild(pCtl);
133  pCtl->setParent(pL4);
134 
135 #if 1
136  pCtl = new Controller();
137  pCtl->setSpecificType(String("ehci-controller"));
138  pCtl->setPciIdentifiers(0x0C, 0x03, 0, 0, 0x20); // EHCI PCI identifiers
139  pCtl->addresses().pushBack(
140  new Device::Address(String("mmio"), 0x48064800, 1024, false));
141  pCtl->setInterruptNumber(77);
142  pL4->addChild(pCtl);
143  pCtl->setParent(pL4);
144 #else
145  pCtl = new Controller();
146  pCtl->setSpecificType(String("ohci-controller"));
147  pCtl->setPciIdentifiers(0x0C, 0x03, 0, 0, 0x10); // OHCI PCI identifiers
148  pCtl->addresses().pushBack(
149  new Device::Address(String("mmio"), 0x48064400, 1024, false));
150  pCtl->setInterruptNumber(76);
151  pL4->addChild(pCtl);
152  pCtl->setParent(pL4);
153 #endif
154 
155  Device::addToRoot(pL4);
156 }
157 
159 {
160  m_Serial[0].setBase(0x49020000); // uart3, RS-232 output on board
161  // m_Serial[1].setBase(0x4806A000); // uart1
162  // m_Serial[2].setBase(0x4806C000); // uart2
163 
164  m_bInitialised = true;
165 }
167 {
168  extern SyncTimer g_SyncTimer;
169 
170  Prcm::instance().initialise(0x48004000);
171 
172  g_SyncTimer.initialise(0x48320000);
173 
174  m_Timers[0].initialise(0, 0x48318000);
175  m_Timers[1].initialise(1, 0x49032000);
176  m_Timers[2].initialise(2, 0x49034000);
177  m_Timers[3].initialise(3, 0x49036000);
178  m_Timers[4].initialise(4, 0x49038000);
179  m_Timers[5].initialise(5, 0x4903A000);
180  m_Timers[6].initialise(6, 0x4903C000);
181  m_Timers[7].initialise(7, 0x4903E000);
182  m_Timers[8].initialise(8, 0x49040000);
183  m_Timers[9].initialise(9, 0x48086000);
184  m_Timers[10].initialise(10, 0x48088000);
185 
186  I2C::instance(0).initialise(0x48070000);
187  I2C::instance(1).initialise(0x48072000);
188  I2C::instance(2).initialise(0x48060000);
189 
190  Gpio::instance().initialise(
191  0x48310000, 0x49050000, 0x49052000, 0x49054000, 0x49056000, 0x49058000);
192 }
194 {
195  return &m_Serial[n];
196 }
198 {
199  return 1; // 3 UARTs attached, only one initialised for now
200 }
202 {
203  return 0; // &m_Vga;
204 }
206 {
207  return 0;
208 }
209 IrqManager *ArmBeagle::getIrqManager()
210 {
211  // TODO
212  return 0;
213 }
215 {
216  return &m_Timers[1];
217 }
219 {
220  return &m_Timers[1];
221 }
222 
224 {
225  return &m_Keyboard;
226 }
227 
229 {
230 }
232 {
233 }
virtual SchedulerTimer * getSchedulerTimer()
Definition: Beagle.cc:214
virtual Keyboard * getKeyboard()
Definition: Beagle.cc:223
virtual size_t getNumSerial()
Definition: Beagle.cc:197
virtual void initialise2()
Called after debugger startup.
Definition: Beagle.cc:166
virtual ~ArmBeagle()
Definition: Beagle.cc:231
virtual size_t getNumVga()
Definition: Beagle.cc:205
virtual void setInterruptNumber(uintptr_t n)
Definition: Device.h:268
virtual Vector< Address * > & addresses()
Definition: Device.h:256
static void addToRoot(Device *device)
Definition: Device.cc:102
virtual Vga * getVga(size_t n)
Definition: Beagle.cc:201
Definition: String.h:49
virtual Timer * getTimer()
Definition: Beagle.cc:218
void initialise(uintptr_t base)
Definition: Prcm.cc:36
Definition: Bus.h:31
virtual Serial * getSerial(size_t n)
Definition: Beagle.cc:193
virtual void setSpecificType(String str)
Definition: Device.h:174
void addChild(Device *pDevice)
Definition: Device.cc:127
void setParent(Device *p)
Definition: Device.h:154
ArmBeagle()
Definition: Beagle.cc:228
void setPciIdentifiers(uint8_t classCode, uint8_t subclassCode, uint16_t vendorId, uint16_t deviceId, uint8_t progIf)
Definition: Device.h:188
virtual void initialiseDeviceTree()
Definition: Beagle.cc:38
virtual void initialise()
Definition: Beagle.cc:158