RTEMS 6.1-rc2
Loading...
Searching...
No Matches
grpwm.h
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 * GRPWM PWM Driver interface.
5 *
6 * COPYRIGHT (c) 2009.
7 * Cobham Gaisler AB.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __GRPWM_H__
32#define __GRPWM_H__
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38extern void grpwm_register_drv (void);
39
40#define GRPWM_IOCTL_GET_CAP 1 /* Get Capabilities */
41#define GRPWM_IOCTL_SET_CONFIG 2 /* Configure one PWM Channel */
42#define GRPWM_IOCTL_SET_SCALER 3 /* Set one scaler */
43#define GRPWM_IOCTL_UPDATE 4 /* Set current period and compare value */
44#define GRPWM_IOCTL_IRQ 5 /* Set up IRQ handling */
45
46/*** Argument for GRPWM_IOCTL_GET_CAP ***/
47
48/* The Capability of the PWM core */
50 int channel_cnt; /* Number of channels */
51 unsigned int pwm; /* Capability1 register */
52 unsigned int wave; /* Capability2 register, Wave form capabilities of last PWM channel, otherwise 0 */
53};
54
55/*** Argument for GRPWM_IOCTL_GET_CONFIG and GRPWM_IOCTL_SET_CONFIG ***/
56
57/* Config One PWM */
59 unsigned int channel; /* Select channel to configure */
60
61 /* Specific for one PWM channel */
62 unsigned int options; /* PWM options */
63 unsigned char dbscaler; /* value greater than 15 disable Dead band */
64 unsigned char scaler_index; /* Select scaler used by PWM channel */
65
66 /* IRQ Setup */
67 unsigned char irqscaler; /* IRQ scaler */
68 void *isr_arg; /* Argument of IRQ handler */
69 void (*isr)(int channel, void *arg); /* Interrupt service routine for this PWM Channel */
70
71 /* Waveform set up */
72 int wave_activate; /* Enables Waveform functionality */
73 unsigned int wave_synccfg; /* Bits [29,30,31] is written into Wave-Config register */
74 unsigned int wave_sync; /* Sets sync compare register */
75 unsigned int *wave_data; /* If not NULL, the Wave RAM is filled with data */
76 unsigned int wave_data_length; /* Length of Wave RAM Data, Also used for wstopaddr */
77};
78
79#define GRPWM_CONFIG_OPTION_FLIP 0x04000000 /* Set this to Flip PWM output pair */
80#define GRPWM_CONFIG_OPTION_DEAD_BAND 0x00200000 /* Dead Band enable */
81#define GRPWM_CONFIG_OPTION_SYMMETRIC 0x00000040 /* If not defined, asymmetric */
82#define GRPWM_CONFIG_OPTION_ASYMMERTIC 0
83#define GRPWM_CONFIG_OPTION_DUAL 0x00000020 /* Dual Compare Enable */
84#define GRPWM_CONFIG_OPTION_PAIR 0x00000004 /* PWM Pair Enable */
85#define GRPWM_CONFIG_OPTION_SINGLE 0x00000000 /* PWM Pair Disable */
86#define GRPWM_CONFIG_OPTION_POLARITY_HIGH 0x00000002 /* PWM Polarity HIGH */
87#define GRPWM_CONFIG_OPTION_POLARITY_LOW 0x00000000 /* PWM Polarity LOW */
88
89#define GRPWM_CONFIG_OPTION_MASK ( \
90 GRPWM_CONFIG_OPTION_DEAD_BAND | GRPWM_CONFIG_OPTION_SYMMETRIC | \
91 GRPWM_CONFIG_OPTION_DUAL | GRPWM_CONFIG_OPTION_PAIR | \
92 GRPWM_CONFIG_OPTION_POLARITY_HIGH \
93 )
94
95/*** Argument for GPPWM_IOCTL_SET_SCALER ***/
96
98 unsigned int index_mask;/* Scaler update index mask, bit 0 = Scaler 0, bit 1 = Scaler 1 */
99 unsigned int values[8]; /* Scaler update values, values[N] is stored into scaler N, if mask & 1<<N is set */
100};
101
102/*** Argument for GRPWM_IOCTL_UPDATE ***/
103
104#define GRPWM_UPDATE_OPTION_ENABLE 0x01 /* Enable the PWM core */
105#define GRPWM_UPDATE_OPTION_DISABLE 0x02 /* Disable the PWM core */
106#define GRPWM_UPDATE_OPTION_PERIOD 0x04 /* Update period register */
107#define GRPWM_UPDATE_OPTION_COMP 0x08 /* Update Compare register */
108#define GRPWM_UPDATE_OPTION_DBCOMP 0x10 /* Update Dead band register */
109#define GRPWM_UPDATE_OPTION_FIX 0x20 /* Update fix output pins (bypass PWM) */
110
111/* FIX PIN bit-mask */
112#define GRPWM_UPDATE_FIX_ENABLE 1 /* Enable force ouput */
113#define GRPWM_UPDATE_FIX_DISABLE 0 /* Disable force ouput */
114#define GRPWM_UPDATE_FIX_0_LOW 0 /* PIN 0 OUPUT: LOW */
115#define GRPWM_UPDATE_FIX_0_HIGH 2 /* PIN 0 OUPUT: HIGH */
116#define GRPWM_UPDATE_FIX_1_LOW 0 /* PIN 1 OUPUT: LOW */
117#define GRPWM_UPDATE_FIX_1_HIGH 4 /* PIN 1 OUPUT: HIGH */
118
120 unsigned int options; /* Select what is updated */
121 unsigned int period; /* Period register content */
122 unsigned int compare; /* Compare register content */
123 unsigned int dbcomp; /* Dead band register content */
124 unsigned char fix; /* Bit-mask that select output on one or two PWM
125 * output pins. Depends on PAIR config value.
126 */
127};
129 unsigned char chanmask; /* Bit Mask select channels */
130 struct grpwm_ioctl_update_chan channels[8]; /* */
131};
132
133/*** Argument for GPPWM_IOCTL_IRQ ***/
134
135#define GRPWM_IRQ_DISABLE 0 /* Disable IRQ */
136#define GRPWM_IRQ_PERIOD 1 /* Enable IRQ on period match */
137#define GRPWM_IRQ_COMPARE 3 /* Enable IRQ on Compare Match */
138#define GRPWM_IRQ_CLEAR 0x10 /* Clear any pending IRQ on GRPWM and IRQ controller */
139
140#define GRPWM_IRQ_CHAN 0x100 /* Channel N is selected, by adding 0x100*N */
141
142#ifdef __cplusplus
143}
144#endif
145
146#endif
Definition: grpwm.h:49
Definition: grpwm.h:58
Definition: grpwm.h:97
Definition: grpwm.h:119
Definition: grpwm.h:128