---+ Interacting with the Cryoelectronics Driver

This page assumes you have a cryoelectronics board booted and running Linux.

The cryoelectronics driver interacts with user applications in two ways:

  • sysfs, which exposes the Linux kernel's internal knobs for twiddling
  • device files

Driver Interaction via sysfs

Let's start by exploring the sysfs structures belonging to the cryoelectronics firmware. On the board, run

$ cd /sys/bus/of_platform/devices
$ ls
81800000.interrupt-  84010000.serial      fffff000.xps-bram-i
81810000.xps-spi     84020000.cryo-seque  mpmc.2
81c00000.ethernet    8fff0000.xps-ll-fif  plb.0
84000000.serial      ff800000.flash       xps-ll-temac.1

Each file in this directory corresponds to a peripheral on the device. We're interested in the cryo-sequencer entry.

$ cd 84020000.cryo-seque
$ ls
bus                  modalias             seq
devspec              name                 subsystem
driver               num_channels         uevent
fifo                 occupancy_ie         version
magic                occupancy_threshold

The important files in this directory are as follows:

File Description
magic "Magic number" that identifies the hardware to the driver; always reads 0x6372796f
version Version identifier; currently 1
fifo/occupancy Number of entries in the FIFO. Without a streamer operating, this should generally read 1024 (indicating the FIFO is full.)
fifo/head Pulls the first entry off of the FIFO. ALERT! Since this "steals" data from other applications using the device, you may mess things up!
seq/freq Current frequency (machine phase increment units) of the cryo sequencer's synthesizer.
seq/channels/*/amp Amplitude of this channel; signed 16-bit number. Maximum is 0x7fff.
seq/channels/*/mixer_bypass '0' if this ADC channel is down-mixed using the synthesizer; '1' otherwise.

It also might be useful to know which channel corresponds to which device inside the cryostat here is the channel mapping.

Physical device inside cryostat Cryoelectronics board name
Ultra Head channel 0
Helium 4 Interpump channel 1
Helium 3 interpump switch channel 2
Interhead channel 4
Helium 3 interpump channel 5
Helium 3 Ultrapump switch channel 6
Exchanger channel 8
Helium 3 Ultrapump channel 9
Main plate channel 12
Helium 4 interpump switch channel 13
Heater He 4 interpump Heater Channel 3
Heater He 3 Interpump Heater channel 4
Heater He 3 ultrapump Heater channel 5
Heater He 4 interpump switch Heater channel 0
Heater He 3 interpump switch Heater channel 1
Heater He 3 ultrapump switch Heater channel 2

You can read the device's current settings (cat seq/freq) or change the settings (echo 0x7ffff > seq/channels/0/amp). This style of interaction replaces the ioctl() calls used in the DfMUX; they're not only easier to use, they require less maintenance and are generally safer.

Interacting with the FIFO Device File

The sysfs interface is good for twiddling device knobs and performing simple (debugging) interaction. A different interface is used to read bulk data out of the FIFO. This process will eventually be greased; for now, the instructions are a little strange but are sufficient to read data off the board.

Once again, with the board booted and running Linux:

  1. on your PC, make sure "netcat" is installed.
  2. run nc -l -p 8989 > dump. (This will stream data into a file called 'dump'.)

On the board, run

$ cd /tmp
$ cat /proc/device | grep cryo
252 cryo
$ mknod cryo c 252 0

This creates the device file corresponding to the cryoelectroncis driver. (The device number in /proc/device and mknod should match.)

Now, you may stream data by running

$ cat /tmp/cryo | nc ip.address.of.your.PC 8989

A couple of comments:

  • Data consists of 32 bit samples in big-endian format. The high 8 bits encodes the channel number (0-32); the low 24 bits contain sample data.
  • The data is in big endian format. You need to convert it via ntohl() before trying to make sense of it.

Programming ADC Registers

ALERT! There appears to be problems reading back register values using this interface. It does, however, appear that register writes occur properly.

Writes to ADC registers are performed using two files (seq/adc_spi_ctl and seq/adc_spi_data) in the devic's sysfs directory. Two ADC registers must be configured in order to properly initialize the ADC. Run the following commands:

$ echo 0x0f000006 > seq/adc_spi_ctl
$ echo 0x0f0003d0 > seq/adc_spi_ctl

This register is defined as follows:

31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Busy 0 ADC Write Enables 0 0 Address Data

The fields are defined as follows:

Field Description
Busy Indicates that the state machine is busy and writes cannot currently be processed
ADC Write Enables Enables writes to a particular ADAC
Address ADC register address
Data Data to write to ADC

Thus, the first write sends the value 0x06 to register 0x00 (STATUS), enabling autocalibration (ACAL) and the analog input bufferse (BUFEN). The second sends 0xd0 to all ADCs' DRATE registers, corresponding to a data rate of 7500 SPS in the ADC's datasheet. Since the clock input is 8 MHz and not 7.68 MHz (as shown in the datasheet), this setting scales to 7812.5 SPS; the actual data rate is 500 Hz * 9 channels = 4500 SPS. ALERT! This number may change as I learn more about the ADC, but it should do for now.


This topic: CryoElectronics > DigitalFMux > CryoElectronicsFirmwareInstructions > CryoElectronicsDriverInteraction Topic revision: r5 - 2009-09-29 - GraemeSmecher
© 2020 Winterland Cosmology Lab, McGill University, Montréal, Québec, Canada