Skip to content

Commit

Permalink
pwms: pwm-ti*: Remove support for local clock gating
Browse files Browse the repository at this point in the history
The PWMSS local clock gating registers have no real purpose on OMAP ARM
devices. These registers were left over registers from DSP IP where the
PRCM doesn't exist. There is a silicon bug where gating and ungating clocks
don't function properly. TRMs will be update to indicate that these
registers shouldn't be touched.

Therefore, all code that accesses the PWMSS_CLKCONFIG or PWMSS_CLKSTATUS
will be removed by this patch with zero loss of functionality by the ECAP
and EPWM drivers.

Signed-off-by: Franklin S Cooper Jr <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
  • Loading branch information
fcooperti authored and nsekhar committed Apr 12, 2016
1 parent a3f4b98 commit aa01567
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 145 deletions.
28 changes: 0 additions & 28 deletions drivers/pwm/pwm-tiecap.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <linux/pwm.h>
#include <linux/of_device.h>

#include "pwm-tipwmss.h"

/* ECAP registers and bits definitions */
#define CAP1 0x08
#define CAP2 0x0C
Expand Down Expand Up @@ -206,7 +204,6 @@ static int ecap_pwm_probe(struct platform_device *pdev)
struct resource *r;
struct clk *clk;
struct ecap_pwm_chip *pc;
u16 status;

pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
if (!pc)
Expand Down Expand Up @@ -243,40 +240,15 @@ static int ecap_pwm_probe(struct platform_device *pdev)
}

pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

status = pwmss_submodule_state_change(pdev->dev.parent,
PWMSS_ECAPCLK_EN);
if (!(status & PWMSS_ECAPCLK_EN_ACK)) {
dev_err(&pdev->dev, "PWMSS config space clock enable failed\n");
ret = -EINVAL;
goto pwmss_clk_failure;
}

pm_runtime_put_sync(&pdev->dev);

platform_set_drvdata(pdev, pc);
return 0;

pwmss_clk_failure:
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pwmchip_remove(&pc->chip);
return ret;
}

static int ecap_pwm_remove(struct platform_device *pdev)
{
struct ecap_pwm_chip *pc = platform_get_drvdata(pdev);

pm_runtime_get_sync(&pdev->dev);
/*
* Due to hardware misbehaviour, acknowledge of the stop_req
* is missing. Hence checking of the status bit skipped.
*/
pwmss_submodule_state_change(pdev->dev.parent, PWMSS_ECAPCLK_STOP_REQ);
pm_runtime_put_sync(&pdev->dev);

pm_runtime_disable(&pdev->dev);
return pwmchip_remove(&pc->chip);
}
Expand Down
29 changes: 0 additions & 29 deletions drivers/pwm/pwm-tiehrpwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include <linux/pm_runtime.h>
#include <linux/of_device.h>

#include "pwm-tipwmss.h"

/* EHRPWM registers and bits definitions */

/* Time base module registers */
Expand Down Expand Up @@ -437,7 +435,6 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
struct resource *r;
struct clk *clk;
struct ehrpwm_pwm_chip *pc;
u16 status;

pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL);
if (!pc)
Expand Down Expand Up @@ -487,27 +484,9 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
}

pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

status = pwmss_submodule_state_change(pdev->dev.parent,
PWMSS_EPWMCLK_EN);
if (!(status & PWMSS_EPWMCLK_EN_ACK)) {
dev_err(&pdev->dev, "PWMSS config space clock enable failed\n");
ret = -EINVAL;
goto pwmss_clk_failure;
}

pm_runtime_put_sync(&pdev->dev);

platform_set_drvdata(pdev, pc);
return 0;

pwmss_clk_failure:
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
pwmchip_remove(&pc->chip);
clk_unprepare(pc->tbclk);
return ret;
}

static int ehrpwm_pwm_remove(struct platform_device *pdev)
Expand All @@ -516,14 +495,6 @@ static int ehrpwm_pwm_remove(struct platform_device *pdev)

clk_unprepare(pc->tbclk);

pm_runtime_get_sync(&pdev->dev);
/*
* Due to hardware misbehaviour, acknowledge of the stop_req
* is missing. Hence checking of the status bit skipped.
*/
pwmss_submodule_state_change(pdev->dev.parent, PWMSS_EPWMCLK_STOP_REQ);
pm_runtime_put_sync(&pdev->dev);

pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
return pwmchip_remove(&pc->chip);
Expand Down
49 changes: 0 additions & 49 deletions drivers/pwm/pwm-tipwmss.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,6 @@
#include <linux/pm_runtime.h>
#include <linux/of_device.h>

#include "pwm-tipwmss.h"

#define PWMSS_CLKCONFIG 0x8 /* Clock gating reg */
#define PWMSS_CLKSTATUS 0xc /* Clock gating status reg */

struct pwmss_info {
void __iomem *mmio_base;
struct mutex pwmss_lock;
u16 pwmss_clkconfig;
};

u16 pwmss_submodule_state_change(struct device *dev, int set)
{
struct pwmss_info *info = dev_get_drvdata(dev);
u16 val;

mutex_lock(&info->pwmss_lock);
val = readw(info->mmio_base + PWMSS_CLKCONFIG);
val |= set;
writew(val , info->mmio_base + PWMSS_CLKCONFIG);
mutex_unlock(&info->pwmss_lock);

return readw(info->mmio_base + PWMSS_CLKSTATUS);
}
EXPORT_SYMBOL(pwmss_submodule_state_change);

static const struct of_device_id pwmss_of_match[] = {
{ .compatible = "ti,am33xx-pwmss" },
{},
Expand All @@ -57,24 +31,10 @@ MODULE_DEVICE_TABLE(of, pwmss_of_match);
static int pwmss_probe(struct platform_device *pdev)
{
int ret;
struct resource *r;
struct pwmss_info *info;
struct device_node *node = pdev->dev.of_node;

info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info)
return -ENOMEM;

mutex_init(&info->pwmss_lock);

r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
info->mmio_base = devm_ioremap_resource(&pdev->dev, r);
if (IS_ERR(info->mmio_base))
return PTR_ERR(info->mmio_base);

pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);
platform_set_drvdata(pdev, info);

/* Populate all the child nodes here... */
ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
Expand All @@ -86,30 +46,21 @@ static int pwmss_probe(struct platform_device *pdev)

static int pwmss_remove(struct platform_device *pdev)
{
struct pwmss_info *info = platform_get_drvdata(pdev);

pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
mutex_destroy(&info->pwmss_lock);
return 0;
}

#ifdef CONFIG_PM_SLEEP
static int pwmss_suspend(struct device *dev)
{
struct pwmss_info *info = dev_get_drvdata(dev);

info->pwmss_clkconfig = readw(info->mmio_base + PWMSS_CLKCONFIG);
pm_runtime_put_sync(dev);
return 0;
}

static int pwmss_resume(struct device *dev)
{
struct pwmss_info *info = dev_get_drvdata(dev);

pm_runtime_get_sync(dev);
writew(info->pwmss_clkconfig, info->mmio_base + PWMSS_CLKCONFIG);
return 0;
}
#endif
Expand Down
39 changes: 0 additions & 39 deletions drivers/pwm/pwm-tipwmss.h

This file was deleted.

0 comments on commit aa01567

Please sign in to comment.