/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
/*
 * Qualcomm PM8XXX Pulse Width Modulation (PWM) driver
 *
 * The HW module is also called LPG (Light Pulse Generator).
 */

#define pr_fmt(fmt) "%s: " fmt, __func__

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/debugfs.h>
#include <linux/mfd/pm8xxx/core.h>
#include <linux/mfd/pm8xxx/pwm.h>

#define PM8XXX_PWM_CHANNELS		3

/*
 * For the lack of better term to distinguish functional
 * differences, hereby, LPG version 0 (V0, v0) denotes
 * PM8058/8921, and version 1 (V1, v1) denotes
 * PM8922/8038.
 */
#define PM8XXX_LPG_V0_PWM_CHANNELS	8
#define PM8XXX_LPG_V1_PWM_CHANNELS	6
#define PM8XXX_LPG_CTL_REGS		7

/* PM8XXX PWM */
#define SSBI_REG_ADDR_PWM1_CTRL1	0x88
#define SSBI_REG_ADDR_PWM1_CTRL2	0x89
#define SSBI_REG_ADDR_PWM_CTL(id, base) (id == 0 ? base : (base + (id << 1)))
#define SSBI_REG_ADDR_PWM_CTL1(id)	SSBI_REG_ADDR_PWM_CTL(id, \
						SSBI_REG_ADDR_PWM1_CTRL1)
#define SSBI_REG_ADDR_PWM_CTL2(id)	SSBI_REG_ADDR_PWM_CTL(id, \
						SSBI_REG_ADDR_PWM1_CTRL2)

#define PM8XXX_PWM_CLK_SEL_SHIFT	6
#define PM8XXX_PWM_CLK_SEL_MASK		0xC0
#define PM8XXX_PWM_PREDIVIDE_SHIFT	5
#define PM8XXX_PWM_PREDIVIDE_MASK	0x20
#define PM8XXX_PWM_M_SHIFT		2
#define PM8XXX_PWM_M_MASK		0x1C
#define PM8XXX_PWM_SIZE_SHIFT		1
#define PM8XXX_PWM_SIZE_MASK		0x02
#define PM8XXX_PWM_VALUE_BIT0		0x01
#define PM8XXX_PWM_DISABLE		0x3F

/* PM8XXX LPG PWM */
#define SSBI_REG_ADDR_LPG_CTL_BASE	0x13C
#define SSBI_REG_ADDR_LPG_CTL(n)	(SSBI_REG_ADDR_LPG_CTL_BASE + (n))
#define SSBI_REG_ADDR_LPG_BANK_SEL	0x143
#define SSBI_REG_ADDR_LPG_BANK_EN	0x144
#define SSBI_REG_ADDR_LPG_LUT_CFG0	0x145
#define SSBI_REG_ADDR_LPG_LUT_CFG1	0x146
#define SSBI_REG_ADDR_LPG_TEST		0x147

/* LPG Control 0 */
#define PM8XXX_PWM_1KHZ_COUNT_MASK	0xF0
#define PM8XXX_PWM_1KHZ_COUNT_SHIFT	4

#define PM8XXX_PWM_1KHZ_COUNT_MAX	15

#define PM8XXX_PWM_OUTPUT_EN		0x08
#define PM8XXX_PWM_PWM_EN		0x04
#define PM8XXX_PWM_RAMP_GEN_EN		0x02
#define PM8XXX_PWM_RAMP_START		0x01

#define PM8XXX_PWM_PWM_START		(PM8XXX_PWM_OUTPUT_EN \
					| PM8XXX_PWM_PWM_EN)
#define PM8XXX_PWM_RAMP_GEN_START	(PM8XXX_PWM_RAMP_GEN_EN \
					| PM8XXX_PWM_RAMP_START)

/* LPG Control 1 */
#define PM8XXX_PWM_REVERSE_EN		0x80
#define PM8XXX_PWM_BYPASS_LUT		0x40
#define PM8XXX_PWM_HIGH_INDEX_MASK	0x3F

/* LPG Control 2 */
#define PM8XXX_PWM_LOOP_EN		0x80
#define PM8XXX_PWM_RAMP_UP		0x40
#define PM8XXX_PWM_LOW_INDEX_MASK	0x3F

/* LPG Control 3 */
#define PM8XXX_PWM_VALUE_BIT7_0		0xFF
#define PM8XXX_PWM_VALUE_BIT5_0		0x3F

/* LPG Control 4 */
#define PM8XXX_PWM_VALUE_BIT8		0x80

#define PM8XXX_LPG_PWM_CLK_SEL_MASK	0x60
#define PM8XXX_LPG_PWM_CLK_SEL_SHIFT	5

#define PM8XXX_PWM_CLK_SEL_NO		0
#define PM8XXX_PWM_CLK_SEL_1KHZ		1
#define PM8XXX_PWM_CLK_SEL_32KHZ	2
#define PM8XXX_PWM_CLK_SEL_19P2MHZ	3

#define PM8XXX_LPG_PWM_PREDIVIDE_MASK	0x18
#define PM8XXX_LPG_PWM_PREDIVIDE_SHIFT	3

#define PM8XXX_PWM_PREDIVIDE_2		0
#define PM8XXX_PWM_PREDIVIDE_3		1
#define PM8XXX_PWM_PREDIVIDE_5		2
#define PM8XXX_PWM_PREDIVIDE_6		3

#define PM8XXX_LPG_PWM_M_MASK		0x07
#define PM8XXX_PWM_M_MIN		0
#define PM8XXX_PWM_M_MAX		7

/* LPG Control 5 */
#define PM8XXX_PWM_PAUSE_COUNT_HI_MASK		0xFC
#define PM8XXX_PWM_PAUSE_COUNT_HI_SHIFT		2

#define PM8XXX_PWM_PAUSE_ENABLE_HIGH		0x02
#define PM8XXX_PWM_SIZE_9_BIT			0x01

/* LPG Control 6 */
#define PM8XXX_PWM_PAUSE_COUNT_LO_MASK		0xFC
#define PM8XXX_PWM_PAUSE_COUNT_LO_SHIFT		2

#define PM8XXX_PWM_PAUSE_ENABLE_LOW		0x02
#define PM8XXX_PWM_RESERVED			0x01

#define PM8XXX_PWM_PAUSE_COUNT_MAX		56 /* < 2^6 = 64 */

/* LPG LUT_CFG1 */
#define PM8XXX_PWM_LUT_READ			0x40

/* TEST */
#define PM8XXX_PWM_DTEST_MASK		0x38
#define PM8XXX_PWM_DTEST_SHIFT		3
#define PM8XXX_PWM_DTEST_BANK_MASK	0x07

/*
 * PWM Frequency = Clock Frequency / (N * T)
 *	or
 * PWM Period = Clock Period * (N * T)
 *	where
 * N = 2^9 or 2^6 for 9-bit or 6-bit PWM size
 * T = Pre-divide * 2^m, where m = 0..7 (exponent)
 *
 * This is the formula to figure out m for the best pre-divide and clock:
 * (PWM Period / N) = (Pre-divide * Clock Period) * 2^m
 */
#define NUM_CLOCKS	3

#define NSEC_1024HZ	(NSEC_PER_SEC / 1024)
#define NSEC_32768HZ	(NSEC_PER_SEC / 32768)
#define NSEC_19P2MHZ	(NSEC_PER_SEC / 19200000)

#define NUM_LPG_PRE_DIVIDE	4
#define NUM_PWM_PRE_DIVIDE	2

#define PRE_DIVIDE_1		1	/* v1 */
#define PRE_DIVIDE_2		2
#define PRE_DIVIDE_3		3
#define PRE_DIVIDE_5		5
#define PRE_DIVIDE_6		6

static unsigned int pt_t[NUM_LPG_PRE_DIVIDE][NUM_CLOCKS] = {
	{	PRE_DIVIDE_2 * NSEC_1024HZ,
		PRE_DIVIDE_2 * NSEC_32768HZ,
		PRE_DIVIDE_2 * NSEC_19P2MHZ,
	},
	{	PRE_DIVIDE_3 * NSEC_1024HZ,
		PRE_DIVIDE_3 * NSEC_32768HZ,
		PRE_DIVIDE_3 * NSEC_19P2MHZ,
	},
	{	PRE_DIVIDE_5 * NSEC_1024HZ,
		PRE_DIVIDE_5 * NSEC_32768HZ,
		PRE_DIVIDE_5 * NSEC_19P2MHZ,
	},
	{	PRE_DIVIDE_6 * NSEC_1024HZ,
		PRE_DIVIDE_6 * NSEC_32768HZ,
		PRE_DIVIDE_6 * NSEC_19P2MHZ,
	},
};

/* Private data */
struct pm8xxx_pwm_chip;

struct pwm_device {
	int			pwm_id;		/* = bank/channel id */
	int			in_use;
	const char		*label;
	struct pm8xxx_pwm_period	period;
	int			pwm_value;
	int			pwm_period;
	int			pwm_duty;
	u8			pwm_lpg_ctl[PM8XXX_LPG_CTL_REGS];
	u8			pwm_ctl1;
	u8			pwm_ctl2;
	int			irq;
	struct pm8xxx_pwm_chip	*chip;
	int			bypass_lut;
	int			dtest_mode_supported;
};

struct pm8xxx_pwm_chip {
	struct pwm_device		*pwm_dev;
	u8				pwm_channels;
	u8				pwm_total_pre_divs;
	u8				bank_mask;
	struct mutex			pwm_mutex;
	struct device			*dev;
	bool				is_lpg_supported;
	bool				is_pwm_enable_sync_workaround_needed;
};

static struct pm8xxx_pwm_chip	*pwm_chip;

struct pm8xxx_pwm_lut {
	/* LUT parameters */
	int	lut_duty_ms;
	int	lut_lo_index;
	int	lut_hi_index;
	int	lut_pause_hi;
	int	lut_pause_lo;
	int	flags;
};

static const u16 duty_msec[PM8XXX_PWM_1KHZ_COUNT_MAX + 1] = {
	0, 1, 2, 3, 4, 6, 8, 16, 18, 24, 32, 36, 64, 128, 256, 512
};

static const u16 pause_count[PM8XXX_PWM_PAUSE_COUNT_MAX + 1] = {
	1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
	23, 28, 31, 42, 47, 56, 63, 83, 94, 111, 125, 167, 188, 222, 250, 333,
	375, 500, 667, 750, 800, 900, 1000, 1100,
	1200, 1300, 1400, 1500, 1600, 1800, 2000, 2500,
	3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500,
	7000
};

/* Internal functions */
static void pm8xxx_pwm_save(u8 *u8p, u8 mask, u8 val)
{
	*u8p &= ~mask;
	*u8p |= val & mask;
}

static int pm8xxx_pwm_bank_enable(struct pwm_device *pwm, int enable)
{
	int	rc;
	u8	reg;
	struct pm8xxx_pwm_chip	*chip;

	chip = pwm->chip;

	if (enable)
		reg = chip->bank_mask | (1 << pwm->pwm_id);
	else
		reg = chip->bank_mask & ~(1 << pwm->pwm_id);

	rc = pm8xxx_writeb(chip->dev->parent, SSBI_REG_ADDR_LPG_BANK_EN, reg);
	if (rc) {
		pr_err("pm8xxx_writeb(): rc=%d (Enable LPG Bank)\n", rc);
		return rc;
	}
	chip->bank_mask = reg;

	return 0;
}

static int pm8xxx_pwm_bank_sel(struct pwm_device *pwm)
{
	int	rc;

	rc = pm8xxx_writeb(pwm->chip->dev->parent, SSBI_REG_ADDR_LPG_BANK_SEL,
			   pwm->pwm_id);
	if (rc)
		pr_err("pm8xxx_writeb(): rc=%d (Select PWM Bank)\n", rc);
	return rc;
}

static int pm8xxx_pwm_start(struct pwm_device *pwm, int start, int ramp_start)
{
	int	rc;
	u8	reg;

	if (start) {
		reg = pwm->pwm_lpg_ctl[0] | PM8XXX_PWM_PWM_START;
		if (ramp_start)
			reg |= PM8XXX_PWM_RAMP_GEN_START;
		else
			reg &= ~PM8XXX_PWM_RAMP_GEN_START;
	} else {
		reg = pwm->pwm_lpg_ctl[0] & ~PM8XXX_PWM_PWM_START;
		reg &= ~PM8XXX_PWM_RAMP_GEN_START;
	}

	rc = pm8xxx_writeb(pwm->chip->dev->parent, SSBI_REG_ADDR_LPG_CTL(0),
			   reg);
	if (rc)
		pr_err("pm8xxx_writeb(): rc=%d (Enable PWM Ctl 0)\n", rc);
	else
		pwm->pwm_lpg_ctl[0] = reg;
	return rc;
}

static int pm8xxx_pwm_disable(struct pwm_device *pwm)
{
	int	rc;
	u8	reg;

	reg = pwm->pwm_ctl1 & PM8XXX_PWM_DISABLE;

	rc = pm8xxx_writeb(pwm->chip->dev->parent,
			SSBI_REG_ADDR_PWM_CTL1(pwm->pwm_id), reg);

	if (rc)
		pr_err("pm8xxx_writeb(): rc=%d (Disable PWM Ctl %d)\n", rc,
								pwm->pwm_id);
	return rc;
}

static int pm8xxx_pwm_enable(struct pwm_device *pwm)
{
	/**
	 * A kind of best Effort: Just write the clock information that
	 * we have in the register.
	 */
	int	rc;

	rc = pm8xxx_writeb(pwm->chip->dev->parent,
			SSBI_REG_ADDR_PWM_CTL1(pwm->pwm_id), pwm->pwm_ctl1);

	if (rc)
		pr_err("pm8xxx_writeb(): rc=%d (Enable PWM Ctl %d)\n", rc,
								pwm->pwm_id);
	return rc;
}

static void pm8xxx_pwm_calc_period(unsigned int period_us,
				   struct pm8xxx_pwm_period *period)
{
	int	n, m, clk, div;
	int	best_m, best_div, best_clk;
	unsigned int	last_err, cur_err, min_err;
	unsigned int	tmp_p, period_n;

	/* PWM Period / N */
	if (period_us < ((unsigned)(-1) / NSEC_PER_USEC)) {
		period_n = (period_us * NSEC_PER_USEC) >> 6;
		n = 6;
	} else {
		period_n = (period_us >> 9) * NSEC_PER_USEC;
		n = 9;
	}

	min_err = last_err = (unsigned)(-1);
	best_m = 0;
	best_clk = 0;
	best_div = 0;
	for (clk = 0; clk < NUM_CLOCKS; clk++) {
		for (div = 0; div < pwm_chip->pwm_total_pre_divs; div++) {
			/* period_n = (PWM Period / N) */
			/* tmp_p = (Pre-divide * Clock Period) * 2^m */
			tmp_p = pt_t[div][clk];
			for (m = 0; m <= PM8XXX_PWM_M_MAX; m++) {
				if (period_n > tmp_p)
					cur_err = period_n - tmp_p;
				else
					cur_err = tmp_p - period_n;

				if (cur_err < min_err) {
					min_err = cur_err;
					best_m = m;
					best_clk = clk;
					best_div = div;
				}

				if (m && cur_err > last_err)
					/* Break for bigger cur_err */
					break;

				last_err = cur_err;
				tmp_p <<= 1;
			}
		}
	}

	/* Use higher resolution */
	if (best_m >= 3 && n == 6) {
		n += 3;
		best_m -= 3;
	}

	period->pwm_size = n;
	period->clk = best_clk;
	period->pre_div = best_div;
	period->pre_div_exp = best_m;
}

static void pm8xxx_pwm_calc_pwm_value(struct pwm_device *pwm,
				      unsigned int period_us,
				      unsigned int duty_us)
{
	unsigned int max_pwm_value, tmp;

	/* Figure out pwm_value with overflow handling */
	tmp = 1 << (sizeof(tmp) * 8 - pwm->period.pwm_size);
	if (duty_us < tmp) {
		tmp = duty_us << pwm->period.pwm_size;
		pwm->pwm_value = tmp / period_us;
	} else {
		tmp = period_us >> pwm->period.pwm_size;
		pwm->pwm_value = duty_us / tmp;
	}
	max_pwm_value = (1 << pwm->period.pwm_size) - 1;
	if (pwm->pwm_value > max_pwm_value)
		pwm->pwm_value = max_pwm_value;
}

static int pm8xxx_pwm_change_table(struct pwm_device *pwm, int duty_pct[],
				   int start_idx, int len, int raw_value)
{
	unsigned int pwm_value, max_pwm_value;
	u8	cfg0, cfg1;
	int	i, pwm_size;
	int	rc = 0;

	pwm_size = (pwm->pwm_lpg_ctl[5] & PM8XXX_PWM_SIZE_9_BIT) ? 9 : 6;
	max_pwm_value = (1 << pwm_size) - 1;
	for (i = 0; i < len; i++) {
		if (raw_value)
			pwm_value = duty_pct[i];
		else
			pwm_value = (duty_pct[i] << pwm_size) / 100;

		if (pwm_value > max_pwm_value)
			pwm_value = max_pwm_value;
		cfg0 = pwm_value;
		cfg1 = (pwm_value >> 1) & 0x80;
		cfg1 |= start_idx + i;

		rc = pm8xxx_writeb(pwm->chip->dev->parent,
				   SSBI_REG_ADDR_LPG_LUT_CFG0, cfg0);
		if (rc)
			break;

		rc = pm8xxx_writeb(pwm->chip->dev->parent,
				   SSBI_REG_ADDR_LPG_LUT_CFG1, cfg1);
		if (rc)
			break;
	}
	return rc;
}

static void pm8xxx_pwm_save_index(struct pwm_device *pwm,
				   int low_idx, int high_idx, int flags)
{
	pwm->pwm_lpg_ctl[1] = high_idx & PM8XXX_PWM_HIGH_INDEX_MASK;
	pwm->pwm_lpg_ctl[2] = low_idx & PM8XXX_PWM_LOW_INDEX_MASK;

	if (flags & PM_PWM_LUT_REVERSE)
		pwm->pwm_lpg_ctl[1] |= PM8XXX_PWM_REVERSE_EN;
	if (flags & PM_PWM_LUT_RAMP_UP)
		pwm->pwm_lpg_ctl[2] |= PM8XXX_PWM_RAMP_UP;
	if (flags & PM_PWM_LUT_LOOP)
		pwm->pwm_lpg_ctl[2] |= PM8XXX_PWM_LOOP_EN;
}

static void pm8xxx_pwm_save_period(struct pwm_device *pwm)
{
	u8	mask, val;

	if (pwm_chip->is_lpg_supported) {
		val = ((pwm->period.clk + 1) << PM8XXX_LPG_PWM_CLK_SEL_SHIFT)
			& PM8XXX_LPG_PWM_CLK_SEL_MASK;
		val |= (pwm->period.pre_div << PM8XXX_LPG_PWM_PREDIVIDE_SHIFT)
			& PM8XXX_LPG_PWM_PREDIVIDE_MASK;
		val |= pwm->period.pre_div_exp & PM8XXX_LPG_PWM_M_MASK;
		mask = PM8XXX_LPG_PWM_CLK_SEL_MASK |
			PM8XXX_LPG_PWM_PREDIVIDE_MASK | PM8XXX_LPG_PWM_M_MASK;
		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[4], mask, val);

		val = (pwm->period.pwm_size > 6) ? PM8XXX_PWM_SIZE_9_BIT : 0;
		mask = PM8XXX_PWM_SIZE_9_BIT;
		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[5], mask, val);
	} else {
		val = ((pwm->period.clk + 1) << PM8XXX_PWM_CLK_SEL_SHIFT)
			& PM8XXX_PWM_CLK_SEL_MASK;
		val |= (pwm->period.pre_div << PM8XXX_PWM_PREDIVIDE_SHIFT)
			& PM8XXX_PWM_PREDIVIDE_MASK;
		val |= (pwm->period.pre_div_exp << PM8XXX_PWM_M_SHIFT)
				& PM8XXX_PWM_M_MASK;
		val |= (((pwm->period.pwm_size > 6) ? PM8XXX_PWM_SIZE_9_BIT : 0)
			<< PM8XXX_PWM_SIZE_SHIFT) & PM8XXX_PWM_SIZE_MASK;

		mask = PM8XXX_PWM_CLK_SEL_MASK | PM8XXX_PWM_PREDIVIDE_MASK |
			PM8XXX_PWM_M_MASK | PM8XXX_PWM_SIZE_MASK;
		pm8xxx_pwm_save(&pwm->pwm_ctl1, mask, val);
	}
}

static void pm8xxx_pwm_save_pwm_value(struct pwm_device *pwm)
{
	u8	mask, val;

	if (pwm_chip->is_lpg_supported) {
		val = (pwm->period.pwm_size > 6) ? (pwm->pwm_value >> 1) : 0;
		pwm->pwm_lpg_ctl[3] = pwm->pwm_value;
		mask = PM8XXX_PWM_VALUE_BIT8;
		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[4], mask, val);
	} else {
		val = (pwm->period.pwm_size > 6) ? (pwm->pwm_value >> 8) : 0;
		pwm->pwm_ctl2 = pwm->pwm_value;
		mask = PM8XXX_PWM_VALUE_BIT0;
		pm8xxx_pwm_save(&pwm->pwm_ctl1, mask, val);
	}
}

static void pm8xxx_pwm_save_duty_time(struct pwm_device *pwm,
				      struct pm8xxx_pwm_lut *lut)
{
	int	i;
	u8	mask, val;

	/* Linear search for duty time */
	for (i = 0; i < PM8XXX_PWM_1KHZ_COUNT_MAX; i++) {
		if (duty_msec[i] >= lut->lut_duty_ms)
			break;
	}
	val = i << PM8XXX_PWM_1KHZ_COUNT_SHIFT;

	mask = PM8XXX_PWM_1KHZ_COUNT_MASK;
	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[0], mask, val);
}

static void pm8xxx_pwm_save_pause(struct pwm_device *pwm,
				  struct pm8xxx_pwm_lut *lut)
{
	int	i, pause_cnt, time_cnt;
	u8	mask, val;

	time_cnt = (pwm->pwm_lpg_ctl[0] & PM8XXX_PWM_1KHZ_COUNT_MASK)
				>> PM8XXX_PWM_1KHZ_COUNT_SHIFT;
	if (lut->flags & PM_PWM_LUT_PAUSE_HI_EN) {
		pause_cnt = (lut->lut_pause_hi + duty_msec[time_cnt] / 2)
				/ duty_msec[time_cnt];
		/* Linear search for pause time */
		for (i = 0; i < PM8XXX_PWM_PAUSE_COUNT_MAX; i++) {
			if (pause_count[i] >= pause_cnt)
				break;
		}
		val = (i << PM8XXX_PWM_PAUSE_COUNT_HI_SHIFT) &
			PM8XXX_PWM_PAUSE_COUNT_HI_MASK;
		val |= PM8XXX_PWM_PAUSE_ENABLE_HIGH;
	} else {
		val = 0;
	}

	mask = PM8XXX_PWM_PAUSE_COUNT_HI_MASK | PM8XXX_PWM_PAUSE_ENABLE_HIGH;
	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[5], mask, val);

	if (lut->flags & PM_PWM_LUT_PAUSE_LO_EN) {
		/* Linear search for pause time */
		pause_cnt = (lut->lut_pause_lo + duty_msec[time_cnt] / 2)
				/ duty_msec[time_cnt];
		for (i = 0; i < PM8XXX_PWM_PAUSE_COUNT_MAX; i++) {
			if (pause_count[i] >= pause_cnt)
				break;
		}
		val = (i << PM8XXX_PWM_PAUSE_COUNT_LO_SHIFT) &
			PM8XXX_PWM_PAUSE_COUNT_LO_MASK;
		val |= PM8XXX_PWM_PAUSE_ENABLE_LOW;
	} else {
		val = 0;
	}

	mask = PM8XXX_PWM_PAUSE_COUNT_LO_MASK | PM8XXX_PWM_PAUSE_ENABLE_LOW;
	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[6], mask, val);
}

static int pm8xxx_pwm_write(struct pwm_device *pwm)
{
	int rc = 0;

	rc = pm8xxx_writeb(pwm->chip->dev->parent,
			   SSBI_REG_ADDR_PWM_CTL1(pwm->pwm_id),
			   pwm->pwm_ctl1);
	if (rc) {
		pr_err("pm8xxx_writeb() failed: rc=%d (PWM Ctl1[%d])\n",
							rc, pwm->pwm_id);
		return rc;
	}

	rc = pm8xxx_writeb(pwm->chip->dev->parent,
			   SSBI_REG_ADDR_PWM_CTL2(pwm->pwm_id),
			   pwm->pwm_ctl2);
	if (rc) {
		pr_err("pm8xxx_writeb() failed: rc=%d (PWM Ctl2[%d])\n",
							rc, pwm->pwm_id);
		return rc;
	}

	return rc;
}

static int pm8xxx_lpg_pwm_write(struct pwm_device *pwm, int start, int end)
{
	int	i, rc;

	/* Write in reverse way so 0 would be the last */
	for (i = end - 1; i >= start; i--) {
		rc = pm8xxx_writeb(pwm->chip->dev->parent,
				   SSBI_REG_ADDR_LPG_CTL(i),
				   pwm->pwm_lpg_ctl[i]);
		if (rc) {
			pr_err("pm8xxx_writeb(): rc=%d (PWM Ctl[%d])\n", rc, i);
			return rc;
		}
	}

	return 0;
}

static int pm8xxx_pwm_change_lut(struct pwm_device *pwm,
				 struct pm8xxx_pwm_lut *lut)
{
	int	rc;

	pm8xxx_pwm_save_index(pwm, lut->lut_lo_index,
			     lut->lut_hi_index, lut->flags);
	pm8xxx_pwm_save_duty_time(pwm, lut);
	pm8xxx_pwm_save_pause(pwm, lut);
	pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[1], PM8XXX_PWM_BYPASS_LUT, 0);

	pm8xxx_pwm_bank_sel(pwm);
	rc = pm8xxx_lpg_pwm_write(pwm, 0, 7);

	return rc;
}

static int pm8xxx_pwm_set_dtest(struct pwm_device *pwm, int enable)
{
	int	rc;
	u8	reg;

	reg = pwm->pwm_id & PM8XXX_PWM_DTEST_BANK_MASK;

	if (enable) {
		/* Observe LPG_OUT on DTEST1*/
		reg |= (1 << PM8XXX_PWM_DTEST_SHIFT) &
				PM8XXX_PWM_DTEST_MASK;
	}

	rc = pm8xxx_writeb(pwm->chip->dev->parent,
			SSBI_REG_ADDR_LPG_TEST, reg);
	if (rc)
		pr_err("pm8xxx_write(DTEST=0x%x) failed: rc=%d\n",
							reg, rc);

	return rc;
}

/* APIs */
/**
 * pwm_request - request a PWM device
 * @pwm_id: PWM id or channel
 * @label: the label to identify the user
 */
struct pwm_device *pwm_request(int pwm_id, const char *label)
{
	struct pwm_device	*pwm;

	if (pwm_chip == NULL) {
		pr_err("No pwm_chip\n");
		return ERR_PTR(-ENODEV);
	}

	if (pwm_id >= pwm_chip->pwm_channels || pwm_id < 0) {
		pr_err("Invalid pwm_id: %d with %s\n",
		       pwm_id, label ? label : ".");
		return ERR_PTR(-EINVAL);
	}

	mutex_lock(&pwm_chip->pwm_mutex);
	pwm = &pwm_chip->pwm_dev[pwm_id];
	if (!pwm->in_use) {
		pwm->in_use = 1;
		pwm->label = label;
	} else {
		pwm = ERR_PTR(-EBUSY);
	}
	mutex_unlock(&pwm_chip->pwm_mutex);

	return pwm;
}
EXPORT_SYMBOL_GPL(pwm_request);

/**
 * pwm_free - free a PWM device
 * @pwm: the PWM device
 */
void pwm_free(struct pwm_device *pwm)
{
	if (pwm == NULL || IS_ERR(pwm) || pwm->chip == NULL) {
		pr_err("Invalid pwm handle\n");
		return;
	}

	mutex_lock(&pwm->chip->pwm_mutex);
	if (pwm->in_use) {
		if (pwm_chip->is_lpg_supported) {
			pm8xxx_pwm_bank_sel(pwm);
			pm8xxx_pwm_start(pwm, 0, 0);
		} else {
			pm8xxx_pwm_disable(pwm);
		}
		pwm->in_use = 0;
		pwm->label = NULL;
	}
	if (pwm_chip->is_lpg_supported)
		pm8xxx_pwm_bank_enable(pwm, 0);
	mutex_unlock(&pwm->chip->pwm_mutex);
}
EXPORT_SYMBOL_GPL(pwm_free);

/**
 * pwm_config - change a PWM device configuration
 * @pwm: the PWM device
 * @period_us: period in microseconds
 * @duty_us: duty cycle in microseconds
 */
int pwm_config(struct pwm_device *pwm, int duty_us, int period_us)
{
	struct pm8xxx_pwm_period *period;
	int	rc = 0;

	if (pwm == NULL || IS_ERR(pwm) ||
		duty_us > period_us ||
		(unsigned)period_us > PM8XXX_PWM_PERIOD_MAX ||
		(unsigned)period_us < PM8XXX_PWM_PERIOD_MIN) {
		pr_err("Invalid pwm handle or parameters\n");
		return -EINVAL;
	}
	if (pwm->chip == NULL) {
		pr_err("No pwm_chip\n");
		return -ENODEV;
	}

	period = &pwm->period;

	mutex_lock(&pwm->chip->pwm_mutex);

	if (!pwm->in_use) {
		rc = -EINVAL;
		goto out_unlock;
	}

	if (pwm->pwm_period != period_us) {
		pm8xxx_pwm_calc_period(period_us, period);
		pm8xxx_pwm_save_period(pwm);
		pwm->pwm_period = period_us;
	}

	pm8xxx_pwm_calc_pwm_value(pwm, period_us, duty_us);
	pm8xxx_pwm_save_pwm_value(pwm);

	if (pwm_chip->is_lpg_supported) {
		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[1],
				PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT);

		pm8xxx_pwm_bank_sel(pwm);
		rc = pm8xxx_lpg_pwm_write(pwm, 1, 6);
	} else {
		rc = pm8xxx_pwm_write(pwm);
	}

	pr_debug("duty/period=%u/%u usec: pwm_value=%d (of %d)\n",
		 (unsigned)duty_us, (unsigned)period_us,
		 pwm->pwm_value, 1 << period->pwm_size);

out_unlock:
	mutex_unlock(&pwm->chip->pwm_mutex);
	return rc;
}
EXPORT_SYMBOL_GPL(pwm_config);

/**
 * pwm_enable - start a PWM output toggling
 * @pwm: the PWM device
 */
int pwm_enable(struct pwm_device *pwm)
{
	int	rc = 0;

	if (pwm == NULL || IS_ERR(pwm)) {
		pr_err("Invalid pwm handle\n");
		return -EINVAL;
	}
	if (pwm->chip == NULL) {
		pr_err("No pwm_chip\n");
		return -ENODEV;
	}

	mutex_lock(&pwm->chip->pwm_mutex);
	if (!pwm->in_use) {
		pr_err("pwm_id: %d: stale handle?\n", pwm->pwm_id);
		rc = -EINVAL;
	} else {
		if (pwm_chip->is_lpg_supported) {
			if (pwm->dtest_mode_supported)
				pm8xxx_pwm_set_dtest(pwm, 1);

			pm8xxx_pwm_bank_sel(pwm);
			rc = pm8xxx_pwm_bank_enable(pwm, 1);
			pm8xxx_pwm_start(pwm, 1, 0);

			/* In PM8038, due to hardware bug, PWM_VALUE register
			 * needs to be written one more time after enabling
			 * PWM mode.
			 */
			if (pwm->chip->is_pwm_enable_sync_workaround_needed)
				rc = pm8xxx_lpg_pwm_write(pwm, 3, 4);

		} else {
			pm8xxx_pwm_enable(pwm);
		}
	}
	mutex_unlock(&pwm->chip->pwm_mutex);
	return rc;
}
EXPORT_SYMBOL_GPL(pwm_enable);

/**
 * pwm_disable - stop a PWM output toggling
 * @pwm: the PWM device
 */
void pwm_disable(struct pwm_device *pwm)
{
	if (pwm == NULL || IS_ERR(pwm) || pwm->chip == NULL) {
		pr_err("Invalid pwm handle or no pwm_chip\n");
		return;
	}

	mutex_lock(&pwm->chip->pwm_mutex);
	if (pwm->in_use) {
		if (pwm_chip->is_lpg_supported) {
			if (pwm->dtest_mode_supported)
				pm8xxx_pwm_set_dtest(pwm, 0);
			pm8xxx_pwm_bank_sel(pwm);
			pm8xxx_pwm_start(pwm, 0, 0);
			pm8xxx_pwm_bank_enable(pwm, 0);
		} else {
			pm8xxx_pwm_disable(pwm);
		}
	}
	mutex_unlock(&pwm->chip->pwm_mutex);
}
EXPORT_SYMBOL_GPL(pwm_disable);

/**
 * pm8xxx_pwm_config_period - change PWM period
 *
 * @pwm: the PWM device
 * @pwm_p: period in struct pm8xxx_pwm_period
 */
int pm8xxx_pwm_config_period(struct pwm_device *pwm,
			     struct pm8xxx_pwm_period *period)
{
	int			rc;

	if (pwm == NULL || IS_ERR(pwm) || period == NULL)
		return -EINVAL;
	if (pwm->chip == NULL)
		return -ENODEV;

	mutex_lock(&pwm->chip->pwm_mutex);

	if (!pwm->in_use) {
		rc = -EINVAL;
		goto out_unlock;
	}

	pwm->period.pwm_size = period->pwm_size;
	pwm->period.clk = period->clk;
	pwm->period.pre_div = period->pre_div;
	pwm->period.pre_div_exp = period->pre_div_exp;

	pm8xxx_pwm_save_period(pwm);

	if (pwm_chip->is_lpg_supported) {
		pm8xxx_pwm_bank_sel(pwm);
		rc = pm8xxx_lpg_pwm_write(pwm, 4, 6);
	} else {
		rc = pm8xxx_pwm_write(pwm);
	}


out_unlock:
	mutex_unlock(&pwm->chip->pwm_mutex);
	return rc;
}
EXPORT_SYMBOL(pm8xxx_pwm_config_period);

/**
 * pm8xxx_pwm_config_pwm_value - change a PWM device configuration
 * @pwm: the PWM device
 * @pwm_value: the duty cycle in raw PWM value (< 2^pwm_size)
 */
int pm8xxx_pwm_config_pwm_value(struct pwm_device *pwm, int pwm_value)
{
	int	rc = 0;

	if (pwm == NULL || IS_ERR(pwm))
		return -EINVAL;
	if (pwm->chip == NULL)
		return -ENODEV;

	mutex_lock(&pwm->chip->pwm_mutex);

	if (!pwm->in_use || !pwm->pwm_period) {
		rc = -EINVAL;
		goto out_unlock;
	}

	if (pwm->pwm_value == pwm_value)
		goto out_unlock;

	pwm->pwm_value = pwm_value;

	pm8xxx_pwm_save_pwm_value(pwm);

	if (pwm_chip->is_lpg_supported) {
		pm8xxx_pwm_save(&pwm->pwm_lpg_ctl[1],
				PM8XXX_PWM_BYPASS_LUT, PM8XXX_PWM_BYPASS_LUT);
		pm8xxx_pwm_bank_sel(pwm);
		rc = pm8xxx_lpg_pwm_write(pwm, 1, 6);
	} else {
		rc = pm8xxx_pwm_write(pwm);
	}

	if (rc)
		pr_err("[%d]: pm8xxx_pwm_write: rc=%d\n", pwm->pwm_id, rc);

out_unlock:
	mutex_unlock(&pwm->chip->pwm_mutex);
	return rc;
}
EXPORT_SYMBOL_GPL(pm8xxx_pwm_config_pwm_value);

/**
 * pm8xxx_pwm_lut_config - change a PWM device configuration to use LUT
 * @pwm: the PWM device
 * @period_us: period in microseconds
 * @duty_pct: arrary of duty cycles in percent, like 20, 50.
 * @duty_time_ms: time for each duty cycle in milliseconds
 * @start_idx: start index in lookup table from 0 to MAX-1
 * @idx_len: number of index
 * @pause_lo: pause time in milliseconds at low index
 * @pause_hi: pause time in milliseconds at high index
 * @flags: control flags
 */
int pm8xxx_pwm_lut_config(struct pwm_device *pwm, int period_us,
			  int duty_pct[], int duty_time_ms, int start_idx,
			  int idx_len, int pause_lo, int pause_hi, int flags)
{
	struct pm8xxx_pwm_lut	lut;
	struct pm8xxx_pwm_period *period;
	int	len;
	int	rc;

	if (pwm == NULL || IS_ERR(pwm) || !idx_len) {
		pr_err("Invalid pwm handle or idx_len=0\n");
		return -EINVAL;
	}
	if (duty_pct == NULL && !(flags & PM_PWM_LUT_NO_TABLE)) {
		pr_err("Invalid duty_pct with flag\n");
		return -EINVAL;
	}
	if (pwm->chip == NULL) {
		pr_err("No pwm_chip\n");
		return -ENODEV;
	}

	if (pwm->chip->is_lpg_supported == 0) {
		pr_err("LPG module isn't supported\n");
		return -EINVAL;
	}

	if (idx_len >= PM_PWM_LUT_SIZE && start_idx) {
		pr_err("Wrong LUT size or index\n");
		return -EINVAL;
	}
	if ((start_idx + idx_len) > PM_PWM_LUT_SIZE) {
		pr_err("Exceed LUT limit\n");
		return -EINVAL;
	}
	if ((unsigned)period_us > PM8XXX_PWM_PERIOD_MAX ||
		(unsigned)period_us < PM8XXX_PWM_PERIOD_MIN) {
		pr_err("Period out of range\n");
		return -EINVAL;
	}

	period = &pwm->period;
	mutex_lock(&pwm->chip->pwm_mutex);

	if (!pwm->in_use) {
		pr_err("pwm_id: %d: stale handle?\n", pwm->pwm_id);
		rc = -EINVAL;
		goto out_unlock;
	}

	if (pwm->pwm_period != period_us) {
		pm8xxx_pwm_calc_period(period_us, period);
		pm8xxx_pwm_save_period(pwm);
		pwm->pwm_period = period_us;
	}

	len = (idx_len > PM_PWM_LUT_SIZE) ? PM_PWM_LUT_SIZE : idx_len;

	if (flags & PM_PWM_LUT_NO_TABLE)
		goto after_table_write;

	rc = pm8xxx_pwm_change_table(pwm, duty_pct, start_idx, len, 0);
	if (rc) {
		pr_err("pm8xxx_pwm_change_table: rc=%d\n", rc);
		goto out_unlock;
	}

after_table_write:
	lut.lut_duty_ms = duty_time_ms;
	lut.lut_lo_index = start_idx;
	lut.lut_hi_index = start_idx + len - 1;
	lut.lut_pause_lo = pause_lo;
	lut.lut_pause_hi = pause_hi;
	lut.flags = flags;
	pwm->bypass_lut = 0;

	rc = pm8xxx_pwm_change_lut(pwm, &lut);

out_unlock:
	mutex_unlock(&pwm->chip->pwm_mutex);
	return rc;
}
EXPORT_SYMBOL_GPL(pm8xxx_pwm_lut_config);

/**
 * pm8xxx_pwm_lut_enable - control a PWM device to start/stop LUT ramp
 * @pwm: the PWM device
 * @start: to start (1), or stop (0)
 */
int pm8xxx_pwm_lut_enable(struct pwm_device *pwm, int start)
{
	if (pwm == NULL || IS_ERR(pwm)) {
		pr_err("Invalid pwm handle\n");
		return -EINVAL;
	}
	if (pwm->chip == NULL) {
		pr_err("No pwm_chip\n");
		return -ENODEV;
	}
	if (pwm->chip->is_lpg_supported == 0) {
		pr_err("LPG module isn't supported\n");
		return -EINVAL;
	}

	mutex_lock(&pwm->chip->pwm_mutex);
	if (start) {
		if (pwm->dtest_mode_supported)
			pm8xxx_pwm_set_dtest(pwm, 1);

		pm8xxx_pwm_bank_sel(pwm);
		pm8xxx_pwm_bank_enable(pwm, 1);

		pm8xxx_pwm_start(pwm, 1, 1);
	} else {
		if (pwm->dtest_mode_supported)
			pm8xxx_pwm_set_dtest(pwm, 0);

		pm8xxx_pwm_bank_sel(pwm);
		pm8xxx_pwm_start(pwm, 0, 0);

		pm8xxx_pwm_bank_enable(pwm, 0);
	}
	mutex_unlock(&pwm->chip->pwm_mutex);
	return 0;
}
EXPORT_SYMBOL_GPL(pm8xxx_pwm_lut_enable);

#if defined(CONFIG_DEBUG_FS)

struct pm8xxx_pwm_dbg_device;

struct pm8xxx_pwm_user {
	int				pwm_id;
	struct pwm_device		*pwm;
	int				period;
	int				duty_cycle;
	int				enable;
	struct pm8xxx_pwm_dbg_device	*dbgdev;
};

struct pm8xxx_pwm_dbg_device {
	struct mutex		dbg_mutex;
	struct device		*dev;
	struct dentry		*dent;

	struct pm8xxx_pwm_user	*user;
};

static struct pm8xxx_pwm_dbg_device *pmic_dbg_device;

static int dbg_pwm_check_period(int period)
{
	if (period < PM8XXX_PWM_PERIOD_MIN || period > PM8XXX_PWM_PERIOD_MAX) {
		pr_err("period is invalid: %d\n", period);
		return -EINVAL;
	}
	return 0;
}

static int dbg_pwm_check_duty_cycle(int duty_cycle, const char *func_name)
{
	if (duty_cycle <= 0 || duty_cycle > 100) {
		pr_err("%s: duty_cycle is invalid: %d\n",
		      func_name, duty_cycle);
		return -EINVAL;
	}
	return 0;
}

static void dbg_pwm_check_handle(struct pm8xxx_pwm_user *puser)
{
	struct pwm_device *tmp;

	if (puser->pwm == NULL) {
		tmp = pwm_request(puser->pwm_id, "pwm-dbg");
		if (PTR_ERR(puser->pwm)) {
			pr_err("pwm_request: err=%ld\n", PTR_ERR(puser->pwm));
			puser->pwm = NULL;
		} else {
			pr_debug("[id=%d] pwm_request ok\n", puser->pwm_id);
			puser->pwm = tmp;
		}
	}
}

static int dbg_pwm_enable_set(void *data, u64 val)
{
	struct pm8xxx_pwm_user	  *puser = data;
	struct pm8xxx_pwm_dbg_device    *dbgdev = puser->dbgdev;
	int     rc;

	mutex_lock(&dbgdev->dbg_mutex);
	rc = dbg_pwm_check_duty_cycle(puser->duty_cycle, __func__);
	if (!rc) {
		puser->enable = val;
		dbg_pwm_check_handle(puser);
		if (puser->pwm) {
			if (puser->enable)
				pwm_enable(puser->pwm);
			else
				pwm_disable(puser->pwm);
		}
	}
	mutex_unlock(&dbgdev->dbg_mutex);
	return 0;
}

static int dbg_pwm_enable_get(void *data, u64 *val)
{
	struct pm8xxx_pwm_user	  *puser = data;
	struct pm8xxx_pwm_dbg_device    *dbgdev = puser->dbgdev;

	mutex_lock(&dbgdev->dbg_mutex);
	*val = puser->enable;
	mutex_unlock(&dbgdev->dbg_mutex);
	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(dbg_pwm_enable_fops,
			dbg_pwm_enable_get, dbg_pwm_enable_set,
			"%lld\n");

static int dbg_pwm_duty_cycle_set(void *data, u64 val)
{
	struct pm8xxx_pwm_user	  *puser = data;
	struct pm8xxx_pwm_dbg_device    *dbgdev = puser->dbgdev;
	int     rc;

	mutex_lock(&dbgdev->dbg_mutex);
	rc = dbg_pwm_check_duty_cycle(val, __func__);
	if (!rc) {
		puser->duty_cycle = val;
		dbg_pwm_check_handle(puser);
		if (puser->pwm) {
			int     duty_us;

			duty_us = puser->duty_cycle * puser->period / 100;
			pwm_config(puser->pwm, duty_us, puser->period);
		}
	}
	mutex_unlock(&dbgdev->dbg_mutex);
	return 0;
}

static int dbg_pwm_duty_cycle_get(void *data, u64 *val)
{
	struct pm8xxx_pwm_user	  *puser = data;
	struct pm8xxx_pwm_dbg_device    *dbgdev = puser->dbgdev;

	mutex_lock(&dbgdev->dbg_mutex);
	*val = puser->duty_cycle;
	mutex_unlock(&dbgdev->dbg_mutex);
	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(dbg_pwm_duty_cycle_fops,
			dbg_pwm_duty_cycle_get, dbg_pwm_duty_cycle_set,
			"%lld\n");

static int dbg_pwm_period_set(void *data, u64 val)
{
	struct pm8xxx_pwm_user	  *puser = data;
	struct pm8xxx_pwm_dbg_device    *dbgdev = puser->dbgdev;
	int     rc;

	mutex_lock(&dbgdev->dbg_mutex);
	rc = dbg_pwm_check_period(val);
	if (!rc)
		puser->period = val;
	mutex_unlock(&dbgdev->dbg_mutex);
	return 0;
}

static int dbg_pwm_period_get(void *data, u64 *val)
{
	struct pm8xxx_pwm_user	  *puser = data;
	struct pm8xxx_pwm_dbg_device    *dbgdev = puser->dbgdev;

	mutex_lock(&dbgdev->dbg_mutex);
	*val = puser->period;
	mutex_unlock(&dbgdev->dbg_mutex);
	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(dbg_pwm_period_fops,
			dbg_pwm_period_get, dbg_pwm_period_set, "%lld\n");

static int __devinit pm8xxx_pwm_dbg_probe(struct device *dev)
{
	struct pm8xxx_pwm_dbg_device    *dbgdev;
	struct dentry		   *dent;
	struct dentry		   *temp;
	struct pm8xxx_pwm_user	  *puser;
	int			     i;
	int rc = 0;

	if (dev == NULL) {
		pr_err("no parent data passed in.\n");
		return -EINVAL;
	}

	dbgdev = kzalloc(sizeof *dbgdev, GFP_KERNEL);
	if (dbgdev == NULL) {
		pr_err("kzalloc() failed.\n");
		return -ENOMEM;
	}

	dbgdev->user = kcalloc(pwm_chip->pwm_channels,
				sizeof(struct pm8xxx_pwm_user), GFP_KERNEL);
	if (dbgdev->user == NULL) {
		pr_err("kcalloc() failed.\n");
		rc = -ENOMEM;
		goto user_error;
	}

	mutex_init(&dbgdev->dbg_mutex);

	dbgdev->dev = dev;

	dent = debugfs_create_dir("pm8xxx-pwm-dbg", NULL);
	if (dent == NULL || IS_ERR(dent)) {
		pr_err("ERR debugfs_create_dir: dent=%p\n", dent);
		rc = -ENOMEM;
		goto dir_error;
	}

	dbgdev->dent = dent;

	for (i = 0; i < pwm_chip->pwm_channels; i++) {
		char pwm_ch[] = "0";

		pwm_ch[0] = '0' + i;
		dent = debugfs_create_dir(pwm_ch, dbgdev->dent);
		if (dent == NULL || IS_ERR(dent)) {
			pr_err("ERR: pwm=%d: dir: dent=%p\n", i, dent);
			rc = -ENOMEM;
			goto debug_error;
		}

		puser = &dbgdev->user[i];
		puser->dbgdev = dbgdev;
		puser->pwm_id = i;
		temp = debugfs_create_file("period", S_IRUGO | S_IWUSR,
				dent, puser, &dbg_pwm_period_fops);
		if (temp == NULL || IS_ERR(temp)) {
			pr_err("ERR: pwm=%d: period: dent=%p\n", i, dent);
			rc = -ENOMEM;
			goto debug_error;
		}

		temp = debugfs_create_file("duty-cycle", S_IRUGO | S_IWUSR,
				dent, puser, &dbg_pwm_duty_cycle_fops);
		if (temp == NULL || IS_ERR(temp)) {
			pr_err("ERR: pwm=%d: duty-cycle: dent=%p\n", i, dent);
			rc = -ENOMEM;
			goto debug_error;
		}

		temp = debugfs_create_file("enable", S_IRUGO | S_IWUSR,
				dent, puser, &dbg_pwm_enable_fops);
		if (temp == NULL || IS_ERR(temp)) {
			pr_err("ERR: pwm=%d: enable: dent=%p\n", i, dent);
			rc = -ENOMEM;
			goto debug_error;
		}
	}

	pmic_dbg_device = dbgdev;

	return 0;

debug_error:
	debugfs_remove_recursive(dbgdev->dent);
dir_error:
	kfree(dbgdev->user);
user_error:
	kfree(dbgdev);
	return rc;
}

static int __devexit pm8xxx_pwm_dbg_remove(void)
{
	if (pmic_dbg_device) {
		kfree(pmic_dbg_device->user);
		debugfs_remove_recursive(pmic_dbg_device->dent);
		kfree(pmic_dbg_device);
	}
	return 0;
}

#else

static int __devinit pm8xxx_pwm_dbg_probe(struct device *dev)
{
	return 0;
}

static int __devexit pm8xxx_pwm_dbg_remove(void)
{
	return 0;
}

#endif

static int __devinit pm8xxx_pwm_probe(struct platform_device *pdev)
{
	const struct pm8xxx_pwm_platform_data *pdata = pdev->dev.platform_data;
	struct pm8xxx_pwm_chip	*chip;
	int	i, dtest_channel;
	enum pm8xxx_version version;

	chip = kzalloc(sizeof *chip, GFP_KERNEL);
	if (chip == NULL) {
		pr_err("kzalloc() failed.\n");
		return -ENOMEM;
	}

	if (pdata != NULL)
		dtest_channel = pdata->dtest_channel;
	else
		dtest_channel = -1;

	mutex_init(&chip->pwm_mutex);

	chip->dev = &pdev->dev;
	pwm_chip = chip;

	version = pm8xxx_get_version(chip->dev->parent);

	if (version == PM8XXX_VERSION_8921 ||
			version == PM8XXX_VERSION_8058 ||
			version == PM8XXX_VERSION_8922 ||
			version == PM8XXX_VERSION_8038) {
		chip->is_lpg_supported = 1;
	}

	if (version == PM8XXX_VERSION_8038)
		chip->is_pwm_enable_sync_workaround_needed = 1;
	else
		chip->is_pwm_enable_sync_workaround_needed = 0;

	if (chip->is_lpg_supported) {
		if (version == PM8XXX_VERSION_8922 ||
				version == PM8XXX_VERSION_8038) {
			for (i = 0; i < NUM_CLOCKS; i++)
				pt_t[0][i] /= PRE_DIVIDE_2;
			chip->pwm_channels = PM8XXX_LPG_V1_PWM_CHANNELS;
		} else {
			chip->pwm_channels = PM8XXX_LPG_V0_PWM_CHANNELS;
		}
		chip->pwm_total_pre_divs = NUM_LPG_PRE_DIVIDE;
	} else {
		chip->pwm_channels = PM8XXX_PWM_CHANNELS;
		chip->pwm_total_pre_divs = NUM_PWM_PRE_DIVIDE;
	}

	chip->pwm_dev = kcalloc(chip->pwm_channels, sizeof(struct pwm_device),
								GFP_KERNEL);
	if (chip->pwm_dev == NULL) {
		pr_err("kcalloc() failed.\n");
		mutex_destroy(&chip->pwm_mutex);
		kfree(chip);
		return -ENOMEM;
	}

	for (i = 0; i < chip->pwm_channels; i++) {
		chip->pwm_dev[i].pwm_id = i;
		chip->pwm_dev[i].chip = chip;
		if (i == dtest_channel)
			chip->pwm_dev[i].dtest_mode_supported = 1;
	}

	platform_set_drvdata(pdev, chip);

	if (pm8xxx_pwm_dbg_probe(&pdev->dev) < 0)
		pr_err("could not set up debugfs\n");

	pr_notice("OK\n");
	return 0;
}

static int __devexit pm8xxx_pwm_remove(struct platform_device *pdev)
{
	struct pm8xxx_pwm_chip	*chip = dev_get_drvdata(pdev->dev.parent);

	pm8xxx_pwm_dbg_remove();
	kfree(chip->pwm_dev);
	mutex_destroy(&chip->pwm_mutex);
	platform_set_drvdata(pdev, NULL);
	kfree(chip);
	return 0;
}

static struct platform_driver pm8xxx_pwm_driver = {
	.probe		= pm8xxx_pwm_probe,
	.remove		= __devexit_p(pm8xxx_pwm_remove),
	.driver		= {
		.name = PM8XXX_PWM_DEV_NAME,
		.owner = THIS_MODULE,
	},
};

static int __init pm8xxx_pwm_init(void)
{
	return platform_driver_register(&pm8xxx_pwm_driver);
}

static void __exit pm8xxx_pwm_exit(void)
{
	platform_driver_unregister(&pm8xxx_pwm_driver);
}

subsys_initcall(pm8xxx_pwm_init);
module_exit(pm8xxx_pwm_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("PM8XXX PWM driver");
MODULE_VERSION("1.0");
MODULE_ALIAS("platform:" PM8XXX_PWM_DEV_NAME);
