13f129280SDonghwa Lee /* 23f129280SDonghwa Lee * header file for pwm driver. 33f129280SDonghwa Lee * 4*fc760cb8SSimon Glass * Copyright 2016 Google Inc. 53f129280SDonghwa Lee * Copyright (c) 2011 samsung electronics 63f129280SDonghwa Lee * Donghwa Lee <dh09.lee@samsung.com> 73f129280SDonghwa Lee * 81a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 93f129280SDonghwa Lee */ 103f129280SDonghwa Lee 113f129280SDonghwa Lee #ifndef _pwm_h_ 123f129280SDonghwa Lee #define _pwm_h_ 133f129280SDonghwa Lee 14*fc760cb8SSimon Glass /* struct pwm_ops: Operations for the PWM uclass */ 15*fc760cb8SSimon Glass struct pwm_ops { 16*fc760cb8SSimon Glass /** 17*fc760cb8SSimon Glass * set_config() - Set the PWM configuration 18*fc760cb8SSimon Glass * 19*fc760cb8SSimon Glass * @dev: PWM device to update 20*fc760cb8SSimon Glass * @channel: PWM channel to update 21*fc760cb8SSimon Glass * @period_ns: PWM period in nanoseconds 22*fc760cb8SSimon Glass * @duty_ns: PWM duty period in nanoseconds 23*fc760cb8SSimon Glass * @return 0 if OK, -ve on error 24*fc760cb8SSimon Glass */ 25*fc760cb8SSimon Glass int (*set_config)(struct udevice *dev, uint channel, uint period_ns, 26*fc760cb8SSimon Glass uint duty_ns); 27*fc760cb8SSimon Glass 28*fc760cb8SSimon Glass /** 29*fc760cb8SSimon Glass * set_enable() - Enable or disable the PWM 30*fc760cb8SSimon Glass * 31*fc760cb8SSimon Glass * @dev: PWM device to update 32*fc760cb8SSimon Glass * @channel: PWM channel to update 33*fc760cb8SSimon Glass * @enable: true to enable, false to disable 34*fc760cb8SSimon Glass * @return 0 if OK, -ve on error 35*fc760cb8SSimon Glass */ 36*fc760cb8SSimon Glass int (*set_enable)(struct udevice *dev, uint channel, bool enable); 37*fc760cb8SSimon Glass }; 38*fc760cb8SSimon Glass 39*fc760cb8SSimon Glass #define pwm_get_ops(dev) ((struct pwm_ops *)(dev)->driver->ops) 40*fc760cb8SSimon Glass 41*fc760cb8SSimon Glass /** 42*fc760cb8SSimon Glass * pwm_set_config() - Set the PWM configuration 43*fc760cb8SSimon Glass * 44*fc760cb8SSimon Glass * @dev: PWM device to update 45*fc760cb8SSimon Glass * @channel: PWM channel to update 46*fc760cb8SSimon Glass * @period_ns: PWM period in nanoseconds 47*fc760cb8SSimon Glass * @duty_ns: PWM duty period in nanoseconds 48*fc760cb8SSimon Glass * @return 0 if OK, -ve on error 49*fc760cb8SSimon Glass */ 50*fc760cb8SSimon Glass int pwm_set_config(struct udevice *dev, uint channel, uint period_ns, 51*fc760cb8SSimon Glass uint duty_ns); 52*fc760cb8SSimon Glass 53*fc760cb8SSimon Glass /** 54*fc760cb8SSimon Glass * pwm_set_enable() - Enable or disable the PWM 55*fc760cb8SSimon Glass * 56*fc760cb8SSimon Glass * @dev: PWM device to update 57*fc760cb8SSimon Glass * @channel: PWM channel to update 58*fc760cb8SSimon Glass * @enable: true to enable, false to disable 59*fc760cb8SSimon Glass * @return 0 if OK, -ve on error 60*fc760cb8SSimon Glass */ 61*fc760cb8SSimon Glass int pwm_set_enable(struct udevice *dev, uint channel, bool enable); 62*fc760cb8SSimon Glass 63*fc760cb8SSimon Glass /* Legacy interface */ 64*fc760cb8SSimon Glass #ifndef CONFIG_DM_PWM 653f129280SDonghwa Lee int pwm_init (int pwm_id, int div, int invert); 663f129280SDonghwa Lee int pwm_config (int pwm_id, int duty_ns, int period_ns); 673f129280SDonghwa Lee int pwm_enable (int pwm_id); 683f129280SDonghwa Lee void pwm_disable (int pwm_id); 69*fc760cb8SSimon Glass #endif 703f129280SDonghwa Lee 713f129280SDonghwa Lee #endif /* _pwm_h_ */ 72