CPU_ELAN(4) BSD/i386 Kernel Interfaces Manual CPU_ELAN(4)NAME
CPU_ELAN -- AMD Elan 520 CPU support
SYNOPSIS
options CPU_ELAN
options CPU_ELAN_PPS
options CPU_ELAN_XTAL
machdep.elan_gpio_config
machdep.elan_freq
options CPU_SOEKRIS
DESCRIPTION
The options CPU_ELAN enables support for the AMD Elan 520 CPU.
A device /dev/elan-mmcr exports the MMCR register bank to userland using mmap(2).
The i8254 timer will be adjusted to the slightly unorthodox frequency 1189161 Hz (32768 * 45 * 25 / 31) employed by the Elan.
A timecounter named ``ELAN'' is implemented using the general purpose timer 2, but it will not be usable unless HZ is configured at 150 or
higher. This timecounter is much better than the ``i8254'' timecounter and should be used at all times.
The machdep.elan_gpio_config sysctl(8) variable enables configuration of the GPIO pins of the CPU. The string must be exactly 32 characters
long. A '-' means the GPIO is unavailable. A 'l' (lower-case ell) configures a led(4) device (active low). A 'L' configures a led(4)
device (active high). A '.' means no configuration for this GPIO. These led(4) devices will be named /dev/led/gpio%d. For meaning of 'P',
'e' and 'E', see under options CPU_ELAN_PPS.
The options CPU_ELAN_XTAL and the machdep.elan_freq sysctl(8) variable can be used to set the CPU clock crystal frequency in Hz. The default
is 33333333 Hz.
The options CPU_ELAN_PPS enables precision timestamping using the RFC2783 PPS-API via the /dev/elan-mmcr device. The resolution will be
approximately 125 nsec and the precision +- 125 nsec. (For 125 nsec read ``4 / CPU clock crystal frequency''.)
The input signal must be connected to the TMR1IN pin and a GPIO pin. The GPIO pin must be configured with a 'P' in machdep.elan_gpio_config.
In addition, one GPIO pin can be configured with either 'e' (active low) or 'E' (active high) to become a ``echo'' output of the input sig-
nal. Please notice that this signal is not suitable for calibration.
If the options CPU_SOEKRIS is given, the support will additionally be tailored to the Soekris Engineering 45xx series of embedded computers.
The ``error'' led will be configured (as /dev/led/error) and the GPIO pins which are not available will be disabled.
SEE ALSO led(4), sysctl(8)HISTORY
The CPU_ELAN code first appeared in FreeBSD 4.7.
AUTHORS
Poul-Henning Kamp <phk@FreeBSD.org>
BSD November 23, 2003 BSD
Check Out this Related Man Page
GPIO(3) BSD Library Functions Manual GPIO(3)NAME
gpio_open, gpio_close -- library to handle GPIO pins
LIBRARY
library ``libgpio''
SYNOPSIS
#include <libgpio.h>
gpio_handle_t
gpio_open(unsigned int unit);
gpio_handle_t
gpio_open_device(const char *device);
void
gpio_close(gpio_handle_t handle);
int
gpio_pin_list(gpio_handle_t handle, gpio_config_t **pcfgs);
int
gpio_pin_config(gpio_handle_t handle, gpio_config *cfg);
int
gpio_pin_set_flags(gpio_handle_t handle, gpio_config_t *cfg);
gpio_value_t
gpio_pin_get(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_set(gpio_handle_t handle, gpio_pin_t pin, gpio_value_t value);
int
gpio_pin_toggle(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_low(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_high(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_input(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_output(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_opendrain(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_pushpull(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_tristate(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_pullup(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_pulldown(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_invin(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_invout(gpio_handle_t handle, gpio_pin_t pin);
int
gpio_pin_pulsate(gpio_handle_t handle, gpio_pin_t pin);
DESCRIPTION
The libgpio library provides an interface to configure GPIO pins. The library operates with a gpio_handle_t opaque type which can be created
with gpio_open() or gpio_open_device(). When no more GPIO operations are needed, this handle can be destroyed with gpio_close().
To get a list of all available pins, one can call gpio_pin_list(). This function takes a pointer to a gpio_config_t which is dynamically
allocated. This pointer should be freed with free(3) when it's no longer necessary.
The function gpio_pin_config() retrieves the current configuration of a pin. The pin number should be passed in via the g_pin variable which
is part of the gpio_config_t structure.
The function gpio_pin_set_flags() configures a pin with the flags passed in by the gpio_config_t structure. The pin number should also be
passed in through the g_pin variable. All other structure members will be ignored by this function. The list of flags can be found in
/usr/include/sys/gpio.h.
The get or set the state of a GPIO pin, the functions gpio_pin_get() and gpio_pin_set() are available, respectively. To toggle the state,
use gpio_pin_toggle().
The functions gpio_pin_low() and gpio_pin_high() are wrappers around gpio_pin_set().
The functions gpio_pin_input(), gpio_pin_output(), gpio_pin_opendrain(), gpio_pin_pushpull(), gpio_pin_tristate(), gpio_pin_pullup(),
gpio_pin_pulldown(), gpio_pin_invin(), gpio_pin_invout() and gpio_pin_pulsate() are wrappers around gpio_pin_set_flags().
EXAMPLES
The following example shows how to configure pin 16 as output and then drive it high:
#include <err.h>
#include <libgpio.h>
gpio_handle_t handle;
handle = gpio_open(0);
if (handle == GPIO_HANDLE_INVALID)
err(1, "gpio_open failed");
gpio_pin_output(handle, 16);
gpio_pin_high(handle, 16);
gpio_close(handle);
The following example shows how to get a configuration of a pin:
gpio_config_t cfg;
cfg.g_pin = 32;
gpio_pin_config(handle, &cfg);
The structure will contain the name of the pin and its flags.
SEE ALSO gpiobus(4), gpioctl(8)HISTORY
The libgpio library first appeared in FreeBSD 11.0.
AUTHORS
The libgpio library was implemented by Rui Paulo <rpaulo@FreeBSD.org>.
BSD November 17, 2014 BSD