blob: 851915eb87a6e253868bcbda25a2a09710a8c0a2 [file] [log] [blame]
Donghwa Lee3f129282011-03-07 21:11:42 +00001/*
2 * header file for pwm driver.
3 *
Simon Glassfc760cb2016-01-21 19:44:54 -07004 * Copyright 2016 Google Inc.
Donghwa Lee3f129282011-03-07 21:11:42 +00005 * Copyright (c) 2011 samsung electronics
6 * Donghwa Lee <dh09.lee@samsung.com>
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
Donghwa Lee3f129282011-03-07 21:11:42 +00009 */
10
11#ifndef _pwm_h_
12#define _pwm_h_
13
Simon Glassfc760cb2016-01-21 19:44:54 -070014/* struct pwm_ops: Operations for the PWM uclass */
15struct pwm_ops {
16 /**
17 * set_config() - Set the PWM configuration
18 *
19 * @dev: PWM device to update
20 * @channel: PWM channel to update
21 * @period_ns: PWM period in nanoseconds
22 * @duty_ns: PWM duty period in nanoseconds
23 * @return 0 if OK, -ve on error
24 */
25 int (*set_config)(struct udevice *dev, uint channel, uint period_ns,
26 uint duty_ns);
27
28 /**
29 * set_enable() - Enable or disable the PWM
30 *
31 * @dev: PWM device to update
32 * @channel: PWM channel to update
33 * @enable: true to enable, false to disable
34 * @return 0 if OK, -ve on error
35 */
36 int (*set_enable)(struct udevice *dev, uint channel, bool enable);
37};
38
39#define pwm_get_ops(dev) ((struct pwm_ops *)(dev)->driver->ops)
40
41/**
42 * pwm_set_config() - Set the PWM configuration
43 *
44 * @dev: PWM device to update
45 * @channel: PWM channel to update
46 * @period_ns: PWM period in nanoseconds
47 * @duty_ns: PWM duty period in nanoseconds
48 * @return 0 if OK, -ve on error
49 */
50int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
51 uint duty_ns);
52
53/**
54 * pwm_set_enable() - Enable or disable the PWM
55 *
56 * @dev: PWM device to update
57 * @channel: PWM channel to update
58 * @enable: true to enable, false to disable
59 * @return 0 if OK, -ve on error
60 */
61int pwm_set_enable(struct udevice *dev, uint channel, bool enable);
62
63/* Legacy interface */
64#ifndef CONFIG_DM_PWM
Donghwa Lee3f129282011-03-07 21:11:42 +000065int pwm_init (int pwm_id, int div, int invert);
66int pwm_config (int pwm_id, int duty_ns, int period_ns);
67int pwm_enable (int pwm_id);
68void pwm_disable (int pwm_id);
Simon Glassfc760cb2016-01-21 19:44:54 -070069#endif
Donghwa Lee3f129282011-03-07 21:11:42 +000070
71#endif /* _pwm_h_ */