From 8848cbcacee9065d65413f19150bcb4e919b82fb Mon Sep 17 00:00:00 2001 From: Joseph Lehrer Date: Sun, 13 Feb 2011 17:29:36 -0800 Subject: tegra: dc: Add PMx PWM control bug 773671 Change-Id: If4265051873809491c80ada9401e48014c15f63d Reviewed-on: http://git-master/r/19397 Reviewed-by: Varun Colbert Tested-by: Varun Colbert --- arch/arm/mach-tegra/include/mach/dc.h | 14 ++++++++++++++ drivers/video/tegra/dc/dc.c | 25 +++++++++++++++++++++++++ drivers/video/tegra/dc/dc_reg.h | 4 ++++ 3 files changed, 43 insertions(+) diff --git a/arch/arm/mach-tegra/include/mach/dc.h b/arch/arm/mach-tegra/include/mach/dc.h index 0f87f993fe52..409d7c6adcb4 100644 --- a/arch/arm/mach-tegra/include/mach/dc.h +++ b/arch/arm/mach-tegra/include/mach/dc.h @@ -225,4 +225,18 @@ int tegra_dc_set_mode(struct tegra_dc *dc, const struct tegra_dc_mode *mode); unsigned tegra_dc_get_out_height(struct tegra_dc *dc); unsigned tegra_dc_get_out_width(struct tegra_dc *dc); +/* PM0 and PM1 signal control */ +#define TEGRA_PWM_PM0 0 +#define TEGRA_PWM_PM1 1 + +struct tegra_dc_pwm_params { + int which_pwm; + unsigned int period; + unsigned int clk_div; + unsigned int clk_select; + unsigned int duty_cycle; +}; + +void tegra_dc_config_pwm(struct tegra_dc *dc, struct tegra_dc_pwm_params *cfg); + #endif diff --git a/drivers/video/tegra/dc/dc.c b/drivers/video/tegra/dc/dc.c index f8159331877a..fe6150f6aabf 100644 --- a/drivers/video/tegra/dc/dc.c +++ b/drivers/video/tegra/dc/dc.c @@ -813,6 +813,31 @@ int tegra_dc_set_mode(struct tegra_dc *dc, const struct tegra_dc_mode *mode) } EXPORT_SYMBOL(tegra_dc_set_mode); +void +tegra_dc_config_pwm(struct tegra_dc *dc, struct tegra_dc_pwm_params *cfg) +{ + unsigned int ctrl; + + ctrl = ((cfg->period << PM_PERIOD_SHIFT) | + (cfg->clk_div << PM_CLK_DIVIDER_SHIFT) | + cfg->clk_select); + + switch (cfg->which_pwm) { + case TEGRA_PWM_PM0: + tegra_dc_writel(dc, ctrl, DC_COM_PM0_CONTROL); + tegra_dc_writel(dc, cfg->duty_cycle, DC_COM_PM0_DUTY_CYCLE); + break; + case TEGRA_PWM_PM1: + tegra_dc_writel(dc, ctrl, DC_COM_PM1_CONTROL); + tegra_dc_writel(dc, cfg->duty_cycle, DC_COM_PM1_DUTY_CYCLE); + break; + default: + dev_err(&dc->ndev->dev, "Error\n"); + return; + } +} +EXPORT_SYMBOL(tegra_dc_config_pwm); + static void tegra_dc_set_out_pin_polars(struct tegra_dc *dc, const struct tegra_dc_out_pin *pins, const unsigned int n_pins) diff --git a/drivers/video/tegra/dc/dc_reg.h b/drivers/video/tegra/dc/dc_reg.h index 240d8a48d03e..1bb2b00f6c71 100644 --- a/drivers/video/tegra/dc/dc_reg.h +++ b/drivers/video/tegra/dc/dc_reg.h @@ -145,6 +145,10 @@ #define DC_COM_PM0_DUTY_CYCLE 0x31d #define DC_COM_PM1_CONTROL 0x31e #define DC_COM_PM1_DUTY_CYCLE 0x31f + +#define PM_PERIOD_SHIFT 18 +#define PM_CLK_DIVIDER_SHIFT 4 + #define DC_COM_SPI_CONTROL 0x320 #define DC_COM_SPI_START_BYTE 0x321 #define DC_COM_HSPI_WRITE_DATA_AB 0x322 -- cgit v1.2.3