linux/drivers/pwm/pwm-twl-led.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Driver for TWL4030/6030 Pulse Width Modulator used as LED driver
 *
 * Copyright (C) 2012 Texas Instruments
 * Author: Peter Ujfalusi <[email protected]>
 *
 * This driver is a complete rewrite of the former pwm-twl6030.c authorded by:
 * Hemanth V <[email protected]>
 *
 * Reference manual for the twl6030 is available at:
 * https://www.ti.com/lit/ds/symlink/twl6030.pdf
 *
 * Limitations:
 * - The twl6030 hardware only supports two period lengths (128 clock ticks and
 *   64 clock ticks), the driver only uses 128 ticks
 * - The hardware doesn't support ON = 0, so the active part of a period doesn't
 *   start at its beginning.
 * - The hardware could support inverted polarity (with a similar limitation as
 *   for normal: the last clock tick is always inactive).
 * - The hardware emits a constant low output when disabled.
 * - A request for .duty_cycle = 0 results in an output wave with one active
 *   clock tick per period. This should better use the disabled state.
 * - The driver only implements setting the relative duty cycle.
 * - The driver doesn't implement .get_state().
 */

#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pwm.h>
#include <linux/mfd/twl.h>
#include <linux/slab.h>

/*
 * This driver handles the PWM driven LED terminals of TWL4030 and TWL6030.
 * To generate the signal on TWL4030:
 *  - LEDA uses PWMA
 *  - LEDB uses PWMB
 * TWL6030 has one LED pin with dedicated LEDPWM
 */

#define TWL4030_LED_MAX
#define TWL6030_LED_MAX

/* Registers, bits and macro for TWL4030 */
#define TWL4030_LEDEN_REG
#define TWL4030_PWMA_REG

#define TWL4030_LEDXON
#define TWL4030_LEDXPWM
#define TWL4030_LED_PINS
#define TWL4030_LED_TOGGLE(led, x)

/* Register, bits and macro for TWL6030 */
#define TWL6030_LED_PWM_CTRL1
#define TWL6030_LED_PWM_CTRL2

#define TWL6040_LED_MODE_HW
#define TWL6040_LED_MODE_ON
#define TWL6040_LED_MODE_OFF
#define TWL6040_LED_MODE_MASK

struct twl_pwmled_chip {};

static inline struct twl_pwmled_chip *to_twl(struct pwm_chip *chip)
{}

static int twl4030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
			      int duty_ns, int period_ns)
{}

static int twl4030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{}

static void twl4030_pwmled_disable(struct pwm_chip *chip,
				   struct pwm_device *pwm)
{}

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


static const struct pwm_ops twl4030_pwmled_ops =;

static int twl6030_pwmled_config(struct pwm_chip *chip, struct pwm_device *pwm,
			      int duty_ns, int period_ns)
{}

static int twl6030_pwmled_enable(struct pwm_chip *chip, struct pwm_device *pwm)
{}

static void twl6030_pwmled_disable(struct pwm_chip *chip,
				   struct pwm_device *pwm)
{}

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

static int twl6030_pwmled_request(struct pwm_chip *chip, struct pwm_device *pwm)
{}

static void twl6030_pwmled_free(struct pwm_chip *chip, struct pwm_device *pwm)
{}

static const struct pwm_ops twl6030_pwmled_ops =;

static int twl_pwmled_probe(struct platform_device *pdev)
{}

#ifdef CONFIG_OF
static const struct of_device_id twl_pwmled_of_match[] =;
MODULE_DEVICE_TABLE(of, twl_pwmled_of_match);
#endif

static struct platform_driver twl_pwmled_driver =;
module_platform_driver();

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