-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This module isn't fully implemented yet. The intention is to allow access to its registers from decode-reg to aid development, but no higher-level functionality has been implemented so far. Identifying the correct SPI core is implemented the same way it was in the ad9510 module.
- Loading branch information
Showing
4 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef ISLA216P_H | ||
#define ISLA216P_H | ||
|
||
#include <modules/fmc250m_4ch.h> | ||
#include <modules/spi.h> | ||
|
||
namespace isla216p { | ||
|
||
class Controller { | ||
spi::Controller spi_regs; | ||
|
||
fmc250m_4ch::Core f250_regs; | ||
mutable std::optional<struct sdb_device_info> f250_devinfo; | ||
mutable std::optional<struct sdb_device_info> spi_first_devinfo, spi_second_devinfo; | ||
|
||
public: | ||
Controller(struct pcie_bars &); | ||
|
||
bool match_devinfo(const struct sdb_device_info &); | ||
void set_devinfo(const struct sdb_device_info &); | ||
|
||
bool get_reg(uint8_t, uint8_t &, spi::Channel); | ||
bool set_reg(uint8_t, uint8_t, spi::Channel); | ||
bool set_defaults(spi::Channel); | ||
}; | ||
|
||
} /* namespace isla216p */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "printer.h" | ||
#include "util.h" | ||
#include "modules/isla216p.h" | ||
|
||
namespace isla216p { | ||
|
||
Controller::Controller(struct pcie_bars &bars): | ||
spi_regs(bars), | ||
f250_regs(bars) | ||
{ | ||
} | ||
|
||
bool Controller::match_devinfo(const struct sdb_device_info &match) | ||
{ | ||
/* the third SPI core after an FMC250M_4CH core is responsible for | ||
* controlling that FMC's ISLA216P chip, and that's how we locate it */ | ||
if (f250_devinfo && spi_first_devinfo && spi_second_devinfo && spi_regs.match_devinfo_lambda(match)) { | ||
/* XXX: should we include a check for the offset between FMC250M_4CH | ||
* and SPI cores? */ | ||
f250_devinfo = std::nullopt; | ||
spi_first_devinfo = std::nullopt; | ||
spi_second_devinfo = std::nullopt; | ||
return true; | ||
} | ||
|
||
if (f250_devinfo && spi_first_devinfo && spi_regs.match_devinfo_lambda(match)) { | ||
spi_second_devinfo = match; | ||
return false; | ||
} | ||
|
||
if (f250_devinfo && spi_regs.match_devinfo_lambda(match)) { | ||
spi_first_devinfo = match; | ||
return false; | ||
} | ||
|
||
if (f250_regs.match_devinfo_lambda(match)) { | ||
f250_devinfo = match; | ||
return false; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
void Controller::set_devinfo(const struct sdb_device_info &new_devinfo) | ||
{ | ||
spi_regs.set_devinfo(new_devinfo); | ||
} | ||
|
||
bool Controller::get_reg(uint8_t addr, uint8_t &rdata, spi::Channel channel) | ||
{ | ||
const unsigned char wdata[] = { | ||
0x80, /* read 1 byte */ | ||
addr, | ||
}; | ||
|
||
return spi_regs.write_read_data(wdata, sizeof wdata, &rdata, sizeof rdata, channel.channel); | ||
} | ||
|
||
bool Controller::set_reg(uint8_t addr, uint8_t rdata, spi::Channel channel) | ||
{ | ||
const unsigned char wdata[] = { | ||
0x00, /* write 1 byte */ | ||
addr, | ||
}; | ||
|
||
return spi_regs.write_read_data(wdata, sizeof wdata, &rdata, sizeof rdata, channel.channel); | ||
} | ||
|
||
bool Controller::set_defaults(spi::Channel) | ||
{ | ||
return false; | ||
} | ||
|
||
} /* namespace isla216p */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters