Path: blob/master/arch/cris/include/asm/etraxgpio.h
15126 views
/*1* The following devices are accessible using this driver using2* GPIO_MAJOR (120) and a couple of minor numbers.3*4* For ETRAX 100LX (CONFIG_ETRAX_ARCH_V10):5* /dev/gpioa minor 0, 8 bit GPIO, each bit can change direction6* /dev/gpiob minor 1, 8 bit GPIO, each bit can change direction7* /dev/leds minor 2, Access to leds depending on kernelconfig8* /dev/gpiog minor 39* g0dir, g8_15dir, g16_23dir, g24 dir configurable in R_GEN_CONFIG10* g1-g7 and g25-g31 is both input and outputs but on different pins11* Also note that some bits change pins depending on what interfaces12* are enabled.13*14* For ETRAX FS (CONFIG_ETRAXFS):15* /dev/gpioa minor 0, 8 bit GPIO, each bit can change direction16* /dev/gpiob minor 1, 18 bit GPIO, each bit can change direction17* /dev/gpioc minor 3, 18 bit GPIO, each bit can change direction18* /dev/gpiod minor 4, 18 bit GPIO, each bit can change direction19* /dev/gpioe minor 5, 18 bit GPIO, each bit can change direction20* /dev/leds minor 2, Access to leds depending on kernelconfig21*22* For ARTPEC-3 (CONFIG_CRIS_MACH_ARTPEC3):23* /dev/gpioa minor 0, 32 bit GPIO, each bit can change direction24* /dev/gpiob minor 1, 32 bit GPIO, each bit can change direction25* /dev/gpioc minor 3, 16 bit GPIO, each bit can change direction26* /dev/gpiod minor 4, 32 bit GPIO, input only27* /dev/leds minor 2, Access to leds depending on kernelconfig28* /dev/pwm0 minor 16, PWM channel 0 on PA3029* /dev/pwm1 minor 17, PWM channel 1 on PA3130* /dev/pwm2 minor 18, PWM channel 2 on PB2631* /dev/ppwm minor 19, PPWM channel32*33*/34#ifndef _ASM_ETRAXGPIO_H35#define _ASM_ETRAXGPIO_H3637#define GPIO_MINOR_FIRST 03839#define ETRAXGPIO_IOCTYPE 434041/* etraxgpio _IOC_TYPE, bits 8 to 15 in ioctl cmd */42#ifdef CONFIG_ETRAX_ARCH_V1043#define GPIO_MINOR_A 044#define GPIO_MINOR_B 145#define GPIO_MINOR_LEDS 246#define GPIO_MINOR_G 347#define GPIO_MINOR_LAST 348#define GPIO_MINOR_LAST_REAL GPIO_MINOR_LAST49#endif5051#ifdef CONFIG_ETRAXFS52#define GPIO_MINOR_A 053#define GPIO_MINOR_B 154#define GPIO_MINOR_LEDS 255#define GPIO_MINOR_C 356#define GPIO_MINOR_D 457#define GPIO_MINOR_E 558#ifdef CONFIG_ETRAX_VIRTUAL_GPIO59#define GPIO_MINOR_V 660#define GPIO_MINOR_LAST 661#else62#define GPIO_MINOR_LAST 563#endif64#define GPIO_MINOR_LAST_REAL GPIO_MINOR_LAST65#endif6667#ifdef CONFIG_CRIS_MACH_ARTPEC368#define GPIO_MINOR_A 069#define GPIO_MINOR_B 170#define GPIO_MINOR_LEDS 271#define GPIO_MINOR_C 372#define GPIO_MINOR_D 473#ifdef CONFIG_ETRAX_VIRTUAL_GPIO74#define GPIO_MINOR_V 675#define GPIO_MINOR_LAST 676#else77#define GPIO_MINOR_LAST 478#endif79#define GPIO_MINOR_FIRST_PWM 1680#define GPIO_MINOR_PWM0 (GPIO_MINOR_FIRST_PWM+0)81#define GPIO_MINOR_PWM1 (GPIO_MINOR_FIRST_PWM+1)82#define GPIO_MINOR_PWM2 (GPIO_MINOR_FIRST_PWM+2)83#define GPIO_MINOR_PPWM (GPIO_MINOR_FIRST_PWM+3)84#define GPIO_MINOR_LAST_PWM GPIO_MINOR_PPWM85#define GPIO_MINOR_LAST_REAL GPIO_MINOR_LAST_PWM86#endif87888990/* supported ioctl _IOC_NR's */9192#define IO_READBITS 0x1 /* read and return current port bits (obsolete) */93#define IO_SETBITS 0x2 /* set the bits marked by 1 in the argument */94#define IO_CLRBITS 0x3 /* clear the bits marked by 1 in the argument */9596/* the alarm is waited for by select() */9798#define IO_HIGHALARM 0x4 /* set alarm on high for bits marked by 1 */99#define IO_LOWALARM 0x5 /* set alarm on low for bits marked by 1 */100#define IO_CLRALARM 0x6 /* clear alarm for bits marked by 1 */101102/* LED ioctl */103#define IO_LEDACTIVE_SET 0x7 /* set active led104* 0=off, 1=green, 2=red, 3=yellow */105106/* GPIO direction ioctl's */107#define IO_READDIR 0x8 /* Read direction 0=input 1=output (obsolete) */108#define IO_SETINPUT 0x9 /* Set direction for bits set, 0=unchanged 1=input,109returns mask with current inputs (obsolete) */110#define IO_SETOUTPUT 0xA /* Set direction for bits set, 0=unchanged 1=output,111returns mask with current outputs (obsolete)*/112113/* LED ioctl extended */114#define IO_LED_SETBIT 0xB115#define IO_LED_CLRBIT 0xC116117/* SHUTDOWN ioctl */118#define IO_SHUTDOWN 0xD119#define IO_GET_PWR_BT 0xE120121/* Bit toggling in driver settings */122/* bit set in low byte0 is CLK mask (0x00FF),123bit set in byte1 is DATA mask (0xFF00)124msb, data_mask[7:0] , clk_mask[7:0]125*/126#define IO_CFG_WRITE_MODE 0xF127#define IO_CFG_WRITE_MODE_VALUE(msb, data_mask, clk_mask) \128( (((msb)&1) << 16) | (((data_mask) &0xFF) << 8) | ((clk_mask) & 0xFF) )129130/* The following 4 ioctl's take a pointer as argument and handles131* 32 bit ports (port G) properly.132* These replaces IO_READBITS,IO_SETINPUT AND IO_SETOUTPUT133*/134#define IO_READ_INBITS 0x10 /* *arg is result of reading the input pins */135#define IO_READ_OUTBITS 0x11 /* *arg is result of reading the output shadow */136#define IO_SETGET_INPUT 0x12 /* bits set in *arg is set to input, */137/* *arg updated with current input pins. */138#define IO_SETGET_OUTPUT 0x13 /* bits set in *arg is set to output, */139/* *arg updated with current output pins. */140141/* The following ioctl's are applicable to the PWM channels only */142143#define IO_PWM_SET_MODE 0x20144145enum io_pwm_mode {146PWM_OFF = 0, /* disabled, deallocated */147PWM_STANDARD = 1, /* 390 kHz, duty cycle 0..255/256 */148PWM_FAST = 2, /* variable freq, w/ 10ns active pulse len */149PWM_VARFREQ = 3, /* individually configurable high/low periods */150PWM_SOFT = 4 /* software generated */151};152153struct io_pwm_set_mode {154enum io_pwm_mode mode;155};156157/* Only for mode PWM_VARFREQ. Period lo/high set in increments of 10ns158* from 10ns (value = 0) to 81920ns (value = 8191)159* (Resulting frequencies range from 50 MHz (10ns + 10ns) down to160* 6.1 kHz (81920ns + 81920ns) at 50% duty cycle, to 12.2 kHz at min/max duty161* cycle (81920 + 10ns or 10ns + 81920ns, respectively).)162*/163#define IO_PWM_SET_PERIOD 0x21164165struct io_pwm_set_period {166unsigned int lo; /* 0..8191 */167unsigned int hi; /* 0..8191 */168};169170/* Only for modes PWM_STANDARD and PWM_FAST.171* For PWM_STANDARD, set duty cycle of 390 kHz PWM output signal, from172* 0 (value = 0) to 255/256 (value = 255).173* For PWM_FAST, set duty cycle of PWM output signal from174* 0% (value = 0) to 100% (value = 255). Output signal in this mode175* is a 10ns pulse surrounded by a high or low level depending on duty176* cycle (except for 0% and 100% which result in a constant output).177* Resulting output frequency varies from 50 MHz at 50% duty cycle,178* down to 390 kHz at min/max duty cycle.179*/180#define IO_PWM_SET_DUTY 0x22181182struct io_pwm_set_duty {183int duty; /* 0..255 */184};185186/* Returns information about the latest PWM pulse.187* lo: Length of the latest low period, in units of 10ns.188* hi: Length of the latest high period, in units of 10ns.189* cnt: Time since last detected edge, in units of 10ns.190*191* The input source to PWM is decied by IO_PWM_SET_INPUT_SRC.192*193* NOTE: All PWM devices is connected to the same input source.194*/195#define IO_PWM_GET_PERIOD 0x23196197struct io_pwm_get_period {198unsigned int lo;199unsigned int hi;200unsigned int cnt;201};202203/* Sets the input source for the PWM input. For the src value see the204* register description for gio:rw_pwm_in_cfg.205*206* NOTE: All PWM devices is connected to the same input source.207*/208#define IO_PWM_SET_INPUT_SRC 0x24209struct io_pwm_set_input_src {210unsigned int src; /* 0..7 */211};212213/* Sets the duty cycles in steps of 1/256, 0 = 0%, 255 = 100% duty cycle */214#define IO_PPWM_SET_DUTY 0x25215216struct io_ppwm_set_duty {217int duty; /* 0..255 */218};219220/* Configuraton struct for the IO_PWMCLK_SET_CONFIG ioctl to configure221* PWM capable gpio pins:222*/223#define IO_PWMCLK_SETGET_CONFIG 0x26224struct gpio_pwmclk_conf {225unsigned int gpiopin; /* The pin number based on the opened device */226unsigned int baseclk; /* The base clock to use, or sw will select one close*/227unsigned int low; /* The number of low periods of the baseclk */228unsigned int high; /* The number of high periods of the baseclk */229};230231/* Examples:232* To get a symmetric 12 MHz clock without knowing anything about the hardware:233* baseclk = 12000000, low = 0, high = 0234* To just get info of current setting:235* baseclk = 0, low = 0, high = 0, the values will be updated by driver.236*/237238#endif239240241