Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: whitequark/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c22b1691eb97
Choose a base ref
...
head repository: whitequark/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c285dfa943ab
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Mar 1, 2019

  1. access.direct.demultiplexer: support pulls in claim_interface().

    This has to be done specifically in claim_interface because it needs
    to be correctly sequenced with relation to IO voltage changes. This
    is not ideal, but works as a first approximation, and it is not clear
    what a significantly better solution would be.
    whitequark committed Mar 1, 2019
    Copy the full SHA
    865ffc4 View commit details
  2. Copy the full SHA
    19839c6 View commit details
  3. Copy the full SHA
    c285dfa View commit details
Showing with 50 additions and 2 deletions.
  1. +37 −1 software/glasgow/access/direct/demultiplexer.py
  2. +13 −1 software/glasgow/applet/i2c_master/__init__.py
38 changes: 37 additions & 1 deletion software/glasgow/access/direct/demultiplexer.py
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ def __init__(self, device):
super().__init__(device)
self._claimed = set()

async def claim_interface(self, applet, mux_interface, args):
async def claim_interface(self, applet, mux_interface, args, pull_low=set(), pull_high=set()):
assert mux_interface._pipe_num not in self._claimed
self._claimed.add(mux_interface._pipe_num)

@@ -55,6 +55,42 @@ async def claim_interface(self, applet, mux_interface, args):
elif hasattr(args, "keep_voltage") and args.keep_voltage:
applet.logger.info("port voltage unchanged")

if self.device.has_pulls:
if self.device.revision == "C0":
if pull_low or pull_high:
applet.logger.error("Glasgow revC0 has severe restrictions on use of configurable "
"pull resistors; device may require power cycling")
await self.device.set_pulls(args.port_spec, pull_low, pull_high)
else:
# Don't touch the pulls; they're either in the power-on reset high-Z state, or
# they have been touched by the user, and we've warned about that above.
pass

else:
await self.device.set_pulls(args.port_spec, pull_low, pull_high)
if pull_low or pull_high:
applet.logger.info("port(s) %s pull resistors configured",
", ".join(sorted(args.port_spec)))
else:
applet.logger.debug("port(s) %s pull resistors disabled",
", ".join(sorted(args.port_spec)))

elif pull_low or pull_high:
# Some applets request pull resistors for bidirectional pins (e.g. I2C). Such applets
# cannot work on revA/B because of the level shifters and the applet should require
# an appropriate revision.
# Some applets, though, request pull resistors for unidirectional, DUT-controlled pins
# (e.g. NAND flash). Such applets can still work on revA/B with appropriate external
# pull resistors, so we spend some additional effort to allow for that.
if pull_low:
applet.logger.warn("port(s) %s requires external pull-down resistors on pins %s",
", ".join(sorted(args.port_spec)),
", ".join(map(str, pull_low)))
if pull_high:
applet.logger.warn("port(s) %s requires external pull-up resistors on pins %s",
", ".join(sorted(args.port_spec)),
", ".join(map(str, pull_high)))

await iface.reset()
return iface

14 changes: 13 additions & 1 deletion software/glasgow/applet/i2c_master/__init__.py
Original file line number Diff line number Diff line change
@@ -266,8 +266,20 @@ def build(self, target, args):
period_cyc=math.ceil(target.sys_clk_freq / (args.bit_rate * 1000))
))

@classmethod
def add_run_arguments(cls, parser, access):
super().add_run_arguments(parser, access)

parser.add_argument(
"--pulls", default=False, action="store_true",
help="enable integrated pull-ups")

async def run(self, device, args):
iface = await device.demultiplexer.claim_interface(self, self.mux_interface, args)
pulls = set()
if args.pulls:
pulls = {args.pin_scl, args.pin_sda}
iface = await device.demultiplexer.claim_interface(self, self.mux_interface, args,
pull_high=pulls)
i2c_iface = I2CMasterInterface(iface, self.logger)
return i2c_iface