FreeNOS
SunxiSystemControl.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <Log.h>
19#include "SunxiSystemControl.h"
20
22{
23 if (m_io.map(IOBase & ~0xfff, PAGESIZE,
26 {
27 ERROR("failed to map I/O memory");
28 return IOError;
29 }
30
31 m_io.setBase(m_io.getBase() + (IOBase & 0xfff));
32 return Success;
33}
34
36{
37 DEBUG("phyAddr = " << (void *)phyAddr);
38
39 u32 val = m_io.read(EmacClock);
40 val &= ~(u32)(EmacClockMask);
41 val |= EmacClockDefault;
42 val |= phyAddr << EmacClockPhyShift;
43 val |= EmacClockLedPoll;
44 val &= ~(u32)(EmacClockShutdown);
45 val |= EmacClockSelect;
46 val &= ~(u32)(EmacClockRmiiEn);
47 m_io.write(EmacClock, val);
48
49 return Success;
50}
void write(u32 reg, u32 data)
write to memory mapped I/O register
Definition ARMIO.h:46
u32 read(u32 reg) const
read from memory mapped I/O register
Definition ARMIO.h:62
void setBase(const Address base)
Set memory I/O base offset.
Definition IO.cpp:33
Result map(Address phys, Size size=4096, Memory::Access access=Memory::Readable|Memory::Writable|Memory::User)
Map I/O address space.
Definition IO.cpp:38
Address getBase() const
Get memory I/O base offset.
Definition IO.cpp:28
@ Success
Definition IO.h:44
Result setupEmac(const uint phyAddr)
Setup EMAC mode.
Arch::IO m_io
Memory I/O object.
Result initialize()
Perform initialization.
static const Address IOBase
Physical base memory address of the SYSCON module.
#define PAGESIZE
ARM uses 4K pages.
Definition ARMConstant.h:97
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
#define ERROR(msg)
Output an error message.
Definition Log.h:61
unsigned int uint
Unsigned integer number.
Definition Types.h:44
#define DEBUG(msg)
Output a debug message to standard output.
Definition Log.h:89
@ User
Definition Memory.h:44
@ Readable
Definition Memory.h:41
@ Device
Definition Memory.h:48
@ Writable
Definition Memory.h:42