]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - sitara-epos/sitara-epos-kernel.git/blob - include/linux/pwm/ehrpwm.h
60d1e0c515a322a5d98d558f6f1172f1a0050662
[sitara-epos/sitara-epos-kernel.git] / include / linux / pwm / ehrpwm.h
1 #ifndef __EHRPWM_H__
2 #define __EHRPWM_H__
4 #include <linux/pwm/pwm.h>
6 #define NCHAN 2
8 struct ehrpwm_pwm;
10 typedef int (*p_fcallback) (struct ehrpwm_pwm *, void *data);
12 struct et_int {
13         void *data;
14         p_fcallback pcallback;
15 };
17 struct tz_int {
18         void *data;
19         p_fcallback pcallback;
20 };
22 struct ehrpwm_pwm {
23         struct pwm_device pwm[NCHAN];
24         struct pwm_device_ops ops;
25         spinlock_t      lock;
26         struct clk      *clk;
27         void __iomem    *mmio_base;
28         unsigned short prescale_val;
29         int irq[2];
30         struct et_int st_etint;
31         struct tz_int st_tzint;
32         u8 version;
33 };
35 enum tz_event {
36         TZ_ONE_SHOT_EVENT = 0,
37         TZ_CYCLE_BY_CYCLE,
38         TZ_OSHT_CBC,
39         TZ_DIS_EVT,
40 };
42 enum config_mask {
43         CONFIG_NS,
44         CONFIG_TICKS,
45 };
47 enum db_edge_delay {
48         RISING_EDGE_DELAY,
49         FALLING_EDGE_DELAY,
50 };
52 struct aq_config_params {
53         unsigned char ch;
54         unsigned char ctreqzro;
55         unsigned char ctreqprd;
56         unsigned char ctreqcmpaup;
57         unsigned char ctreqcmpadown;
58         unsigned char ctreqcmpbup;
59         unsigned char ctreqcmpbdown;
60 };
62 int ehrpwm_tb_set_prescalar_val(struct pwm_device *p, unsigned char
63         clkdiv, unsigned char hspclkdiv);
65 int ehrpwm_tb_config_sync(struct pwm_device *p, unsigned char phsen,
66         unsigned char syncosel);
68 int ehrpwm_tb_set_counter_mode(struct pwm_device *p, unsigned char
69         ctrmode, unsigned char phsdir);
71 int ehrpwm_tb_force_sync(struct pwm_device *p);
73 int ehrpwm_tb_set_periodload(struct pwm_device *p, unsigned char
74                loadmode);
76 int ehrpwm_tb_read_status(struct pwm_device *p, unsigned short *val);
78 int ehrpwm_tb_read_counter(struct pwm_device *p, unsigned short *val);
80 int ehrpwm_tb_set_period(struct pwm_device *p,  unsigned short val);
82 int ehrpwm_tb_set_phase(struct pwm_device *p, unsigned short val);
84 int ehrpwm_cmp_set_cmp_ctl(struct pwm_device *p, unsigned char
85                shdwamode, unsigned char shdwbmode, unsigned char loadamode,
86         unsigned char loadbmode);
88 int ehrpwm_cmp_set_cmp_val(struct pwm_device *p, unsigned char reg,
89         unsigned short val);
91 int ehrpwm_aq_set_act_ctrl(struct pwm_device *p,
92                struct aq_config_params *cfg);
94 int ehrpwm_aq_set_one_shot_act(struct pwm_device  *p, unsigned char ch,
95         unsigned char act);
97 int ehrpwm_aq_ot_frc(struct pwm_device *p, unsigned char ch);
99 int ehrpwm_aq_set_csfrc_load_mode(struct pwm_device *p, unsigned char
100                loadmode);
102 int ehrpwm_aq_continuous_frc(struct pwm_device *p, unsigned char ch,
103         unsigned char act);
105 int ehrpwm_db_get_max_delay(struct pwm_device *p,
106                enum config_mask cfgmask, unsigned long *delay_val);
108 int ehrpwm_db_get_delay(struct pwm_device *p, unsigned char edge,
109         enum config_mask cfgmask, unsigned long *delay_val);
111 int ehrpwm_db_set_delay(struct pwm_device *p, unsigned char edge,
112                 enum config_mask cfgmask, unsigned long delay);
114 int ehrpwm_db_set_mode(struct pwm_device *p, unsigned char inmode,
115                 unsigned char polsel, unsigned char outmode);
117 int ehrpwm_pc_configure(struct pwm_device *p, unsigned char chpduty,
118                 unsigned char chpfreq, unsigned char oshtwidth);
120 int ehrpwm_pc_en_dis(struct pwm_device *p, unsigned char chpen);
122 int ehrpwm_tz_sel_event(struct pwm_device *p, unsigned char input,
123                enum tz_event evt);
125 int ehrpwm_tz_set_action(struct pwm_device *p, unsigned char ch,
126         unsigned char act);
128 int ehrpwm_tz_set_int_en_dis(struct pwm_device *p, enum tz_event event,
129                 unsigned char int_en_dis);
131 int ehrpwm_tz_force_evt(struct pwm_device *p, enum tz_event event);
133 int ehrpwm_tz_read_status(struct pwm_device *p, unsigned short *status);
135 int ehrpwm_tz_clr_evt_status(struct pwm_device *p);
137 int ehrpwm_tz_clr_int_status(struct pwm_device *p);
139 int ehrpwm_et_set_sel_evt(struct pwm_device *p, unsigned char evt,
140                 unsigned char prd);
142 int ehrpwm_et_int_en_dis(struct pwm_device *p, unsigned char en_dis);
144 int ehrpwm_et_read_evt_cnt(struct pwm_device *p, unsigned long *evtcnt);
146 int pwm_et_read_int_status(struct pwm_device *p,
147         unsigned long *status);
149 int ehrpwm_et_frc_int(struct pwm_device *p);
151 int ehrpwm_et_clr_int(struct pwm_device *p);
153 int ehrpwm_hr_set_phase(struct pwm_device *p, unsigned char val);
155 int ehrpwm_hr_set_cmpval(struct pwm_device *p, unsigned char val);
157 int ehrpwm_hr_config(struct pwm_device *p, unsigned char loadmode,
158                 unsigned char ctlmode, unsigned char edgemode);
160 int ehrpwm_et_cb_register(struct pwm_device *p, void *data,
161         p_fcallback cb);
163 int ehrpwm_tz_cb_register(struct pwm_device *p, void *data,
164         p_fcallback cb);
166 int ehrpwm_pwm_suspend(struct pwm_device *p, enum
167                config_mask config_mask,
168                unsigned long val);
170 #define ENABLE 1
171 #define DISABLE 0
173 #endif