uboot/include/pwm.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0+ */
   2/*
   3 * header file for pwm driver.
   4 *
   5 * Copyright 2016 Google Inc.
   6 * Copyright (c) 2011 samsung electronics
   7 * Donghwa Lee <dh09.lee@samsung.com>
   8 */
   9
  10#ifndef _pwm_h_
  11#define _pwm_h_
  12
  13struct udevice;
  14
  15/* struct pwm_ops: Operations for the PWM uclass */
  16struct pwm_ops {
  17        /**
  18         * set_config() - Set the PWM configuration
  19         *
  20         * @dev:        PWM device to update
  21         * @channel:    PWM channel to update
  22         * @period_ns:  PWM period in nanoseconds
  23         * @duty_ns:    PWM duty period in nanoseconds
  24         * @return 0 if OK, -ve on error
  25         */
  26        int (*set_config)(struct udevice *dev, uint channel, uint period_ns,
  27                          uint duty_ns);
  28
  29        /**
  30         * set_enable() - Enable or disable the PWM
  31         *
  32         * @dev:        PWM device to update
  33         * @channel:    PWM channel to update
  34         * @enable:     true to enable, false to disable
  35         * @return 0 if OK, -ve on error
  36         */
  37        int (*set_enable)(struct udevice *dev, uint channel, bool enable);
  38        /**
  39         * set_invert() - Set the PWM invert
  40         *
  41         * @dev:        PWM device to update
  42         * @channel:    PWM channel to update
  43         * @polarity:   true to invert, false to keep normal polarity
  44         * @return 0 if OK, -ve on error
  45         */
  46        int (*set_invert)(struct udevice *dev, uint channel, bool polarity);
  47};
  48
  49#define pwm_get_ops(dev)        ((struct pwm_ops *)(dev)->driver->ops)
  50
  51/**
  52 * pwm_set_config() - Set the PWM configuration
  53 *
  54 * @dev:        PWM device to update
  55 * @channel:    PWM channel to update
  56 * @period_ns:  PWM period in nanoseconds
  57 * @duty_ns:    PWM duty period in nanoseconds
  58 * @return 0 if OK, -ve on error
  59 */
  60int pwm_set_config(struct udevice *dev, uint channel, uint period_ns,
  61                   uint duty_ns);
  62
  63/**
  64 * pwm_set_enable() - Enable or disable the PWM
  65 *
  66 * @dev:        PWM device to update
  67 * @channel:    PWM channel to update
  68 * @enable:     true to enable, false to disable
  69 * @return 0 if OK, -ve on error
  70 */
  71int pwm_set_enable(struct udevice *dev, uint channel, bool enable);
  72
  73/**
  74 * pwm_set_invert() - Set pwm default polarity
  75 *
  76 * @dev:        PWM device to update
  77 * @channel:    PWM channel to update
  78 * @polarity:   true to invert, false to keep normal polarity
  79 * @return 0 if OK, -ve on error
  80 */
  81int pwm_set_invert(struct udevice *dev, uint channel, bool polarity);
  82
  83/* Legacy interface */
  84#ifndef CONFIG_DM_PWM
  85int     pwm_init                (int pwm_id, int div, int invert);
  86int     pwm_config              (int pwm_id, int duty_ns, int period_ns);
  87int     pwm_enable              (int pwm_id);
  88void    pwm_disable             (int pwm_id);
  89#endif
  90
  91#endif /* _pwm_h_ */
  92