linux/drivers/pwm/pwm-stm32.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) STMicroelectronics 2016
 *
 * Author: Gerald Baeza <gerald.baeza@st.com>
 *
 * Inspired by timer-stm32.c from Maxime Coquelin
 *             pwm-atmel.c from Bo Shen
 */

#include <linux/bitfield.h>
#include <linux/mfd/stm32-timers.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/pwm.h>

#define CCMR_CHANNEL_SHIFT
#define CCMR_CHANNEL_MASK
#define MAX_BREAKINPUT

struct stm32_breakinput {};

struct stm32_pwm {};

static inline struct stm32_pwm *to_stm32_pwm_dev(struct pwm_chip *chip)
{}

static u32 active_channels(struct stm32_pwm *dev)
{}

#define TIM_CCER_CC12P
#define TIM_CCER_CC12E
#define TIM_CCER_CC34P
#define TIM_CCER_CC34E

/*
 * Capture using PWM input mode:
 *                              ___          ___
 * TI[1, 2, 3 or 4]: ........._|   |________|
 *                             ^0  ^1       ^2
 *                              .   .        .
 *                              .   .        XXXXX
 *                              .   .   XXXXX     |
 *                              .  XXXXX     .    |
 *                            XXXXX .        .    |
 * COUNTER:        ______XXXXX  .   .        .    |_XXX
 *                 start^       .   .        .        ^stop
 *                      .       .   .        .
 *                      v       v   .        v
 *                                  v
 * CCR1/CCR3:       tx..........t0...........t2
 * CCR2/CCR4:       tx..............t1.........
 *
 * DMA burst transfer:          |            |
 *                              v            v
 * DMA buffer:                  { t0, tx }   { t2, t1 }
 * DMA done:                                 ^
 *
 * 0: IC1/3 snapchot on rising edge: counter value -> CCR1/CCR3
 *    + DMA transfer CCR[1/3] & CCR[2/4] values (t0, tx: doesn't care)
 * 1: IC2/4 snapchot on falling edge: counter value -> CCR2/CCR4
 * 2: IC1/3 snapchot on rising edge: counter value -> CCR1/CCR3
 *    + DMA transfer CCR[1/3] & CCR[2/4] values (t2, t1)
 *
 * DMA done, compute:
 * - Period     = t2 - t0
 * - Duty cycle = t1 - t0
 */
static int stm32_pwm_raw_capture(struct pwm_chip *chip, struct pwm_device *pwm,
				 unsigned long tmo_ms, u32 *raw_prd,
				 u32 *raw_dty)
{}

static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
			     struct pwm_capture *result, unsigned long tmo_ms)
{}

static int stm32_pwm_config(struct stm32_pwm *priv, unsigned int ch,
			    u64 duty_ns, u64 period_ns)
{}

static int stm32_pwm_set_polarity(struct stm32_pwm *priv, unsigned int ch,
				  enum pwm_polarity polarity)
{}

static int stm32_pwm_enable(struct stm32_pwm *priv, unsigned int ch)
{}

static void stm32_pwm_disable(struct stm32_pwm *priv, unsigned int ch)
{}

static int stm32_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
			   const struct pwm_state *state)
{}

static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
				  const struct pwm_state *state)
{}

static int stm32_pwm_get_state(struct pwm_chip *chip,
			       struct pwm_device *pwm, struct pwm_state *state)
{}

static const struct pwm_ops stm32pwm_ops =;

static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,
				    const struct stm32_breakinput *bi)
{}

static int stm32_pwm_apply_breakinputs(struct stm32_pwm *priv)
{}

static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
				       struct device_node *np)
{}

static void stm32_pwm_detect_complementary(struct stm32_pwm *priv)
{}

static unsigned int stm32_pwm_detect_channels(struct regmap *regmap,
					      unsigned int *num_enabled)
{}

static int stm32_pwm_probe(struct platform_device *pdev)
{}

static int stm32_pwm_suspend(struct device *dev)
{}

static int stm32_pwm_resume(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(stm32_pwm_pm_ops, stm32_pwm_suspend, stm32_pwm_resume);

static const struct of_device_id stm32_pwm_of_match[] =;
MODULE_DEVICE_TABLE(of, stm32_pwm_of_match);

static struct platform_driver stm32_pwm_driver =;
module_platform_driver();

MODULE_ALIAS();
MODULE_DESCRIPTION();
MODULE_LICENSE();