FreeNOS
SunxiPowerManagement.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
19
21{
22 if (m_io.map(IOBase & ~0xfff, PAGESIZE,
25 {
26 ERROR("failed to map I/O memory");
27 return IOError;
28 }
29
30 m_io.setBase(m_io.getBase() + (IOBase & 0xfff));
31 return Success;
32}
33
35{
37 {
38 ERROR("invalid coreId " << coreId);
39 return InvalidArgument;
40 }
41
42 // Open up the power clamp for this core
43 for (u32 val = 0x1ff; val != 0; val >>= 1)
44 {
45 m_io.write(CpuPowerClamp + (coreId * sizeof(u32)), val);
46 }
47
48 // Now enable the power for the core
50 return Success;
51}
u8 coreId
Definition IntelACPI.h:1
void unset(Address addr, u32 data)
Unset bits in memory mapped register.
Definition ARMIO.h:122
void write(u32 reg, u32 data)
write to memory mapped I/O register
Definition ARMIO.h:46
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 powerOnCore(const Size coreId)
Power on a processor.
static const Size NumberOfCores
Total number of cores supported.
static const Address IOBase
Physical base memory address of the PRCM module.
Result initialize()
Perform initialization.
Arch::IO m_io
Memory I/O object.
#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 Size
Any sane size indicator cannot go negative.
Definition Types.h:128
@ User
Definition Memory.h:44
@ Readable
Definition Memory.h:41
@ Device
Definition Memory.h:48
@ Writable
Definition Memory.h:42