-Initial support for TPS65950 -Support for changing CPU frequency in prcm driver -Preparations for context switching
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
#include <memory>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <cassert>
|
|
|
|
#include "interfaces.hh"
|
|
#include "drv_tps65950.hh"
|
|
|
|
// OPP 0 1 2 3 4 5 6
|
|
// ARM Freq ret 125 250 500 550 600 720
|
|
// IVA2 Freq ret 90 180 360 400 430 520
|
|
static const uint8_t cpu_opp_volt[] = { 31, 31, 37, 48, 54, 60, 60};
|
|
|
|
// OPP 0 1 2 3
|
|
static const uint8_t core_opp_volt[] = { 31, 31, 37, 44};
|
|
|
|
class TPS65950_impl {
|
|
public:
|
|
TPS65950_impl(II2C& i2c) : i2c_(i2c) {
|
|
i2c_.reg_write(0x49, 0x97, 0x49);
|
|
|
|
uint8_t idcode[4];
|
|
for(int i = 0;i < 4;++i)
|
|
idcode[i] = i2c_.reg_read(0x49, 0x85+i);
|
|
|
|
uint8_t dieid[8];
|
|
for(int i = 0;i < 8;++i)
|
|
dieid[i] = i2c_.reg_read(0x49, 0x89+i);
|
|
|
|
printf("TPS65950 IDCODE: %.2hhu%.2hhu%.2hhu%.2hhu\n",
|
|
idcode[3], idcode[2], idcode[1], idcode[0]);
|
|
printf("\tSerial# %.2hhu%.2hhu%.2hhu%.2hhu%.2hhu%.2hhu%.2hhu%.2hhu\n",
|
|
dieid[7], dieid[6], dieid[5], dieid[4],
|
|
dieid[3], dieid[2], dieid[1], dieid[0]);
|
|
}
|
|
|
|
~TPS65950_impl() {
|
|
}
|
|
|
|
void set_cpu_opp(int opp) {
|
|
assert(opp>=0 && opp<=6);
|
|
|
|
i2c_.reg_write(0x4b, 0xb9, cpu_opp_volt[opp]);
|
|
}
|
|
|
|
void set_core_opp(int opp) {
|
|
assert(opp>=0 && opp<=3);
|
|
|
|
i2c_.reg_write(0x4b, 0xc7, core_opp_volt[opp]);
|
|
}
|
|
|
|
private:
|
|
II2C& i2c_;
|
|
};
|
|
|
|
|
|
TPS65950::TPS65950(II2C& i2c) : impl_{new TPS65950_impl{i2c}} {
|
|
}
|
|
|
|
TPS65950::~TPS65950() {
|
|
}
|
|
|
|
void TPS65950::set_cpu_opp(int opp) {
|
|
impl_->set_cpu_opp(opp);
|
|
}
|
|
|
|
void TPS65950::set_core_opp(int opp) {
|
|
impl_->set_core_opp(opp);
|
|
}
|