Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347117
b: refs/heads/master
c: af0ba00
h: refs/heads/master
i:
  347115: 4c083dd
v: v3
  • Loading branch information
Philip, Avinash authored and Thierry Reding committed Nov 28, 2012
1 parent f129a63 commit 503fd52
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 83af24027b3df1af5c5a9aa9adcdcfeb3429d3be
refs/heads/master: af0ba001d208e117b5f4e4f504672b42a664a7f7
31 changes: 31 additions & 0 deletions trunk/Documentation/devicetree/bindings/pwm/pwm-tipwmss.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
TI SOC based PWM Subsystem

Required properties:
- compatible: Must be "ti,am33xx-pwmss";
- reg: physical base address and size of the registers map.
- address-cells: Specify the number of u32 entries needed in child nodes.
Should set to 1.
- size-cells: specify number of u32 entries needed to specify child nodes size
in reg property. Should set to 1.
- ranges: describes the address mapping of a memory-mapped bus. Should set to
physical address map of child's base address, physical address within
parent's address space and length of the address map. For am33xx,
3 set of child register maps present, ECAP register space, EQEP
register space, EHRPWM register space.

Also child nodes should also populated under PWMSS DT node.

Example:
pwmss0: pwmss@48300000 {
compatible = "ti,am33xx-pwmss";
reg = <0x48300000 0x10>;
ti,hwmods = "epwmss0";
#address-cells = <1>;
#size-cells = <1>;
status = "disabled";
ranges = <0x48300100 0x48300100 0x80 /* ECAP */
0x48300180 0x48300180 0x80 /* EQEP */
0x48300200 0x48300200 0x80>; /* EHRPWM */

/* child nodes go here */
};
11 changes: 11 additions & 0 deletions trunk/drivers/pwm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ config PWM_TEGRA
config PWM_TIECAP
tristate "ECAP PWM support"
depends on SOC_AM33XX
select PWM_TIPWMSS
help
PWM driver support for the ECAP APWM controller found on AM33XX
TI SOC
Expand All @@ -146,13 +147,23 @@ config PWM_TIECAP
config PWM_TIEHRPWM
tristate "EHRPWM PWM support"
depends on SOC_AM33XX
select PWM_TIPWMSS
help
PWM driver support for the EHRPWM controller found on AM33XX
TI SOC

To compile this driver as a module, choose M here: the module
will be called pwm-tiehrpwm.

config PWM_TIPWMSS
bool
depends on SOC_AM33XX && (PWM_TIEHRPWM || PWM_TIECAP)
help
PWM Subsystem driver support for AM33xx SOC.

PWM submodules require PWM config space access from submodule
drivers and require common parent driver support.

config PWM_TWL6030
tristate "TWL6030 PWM support"
depends on TWL4030_CORE
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/pwm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ obj-$(CONFIG_PWM_SPEAR) += pwm-spear.o
obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o
obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o
obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o
obj-$(CONFIG_PWM_TIPWMSS) += pwm-tipwmss.o
obj-$(CONFIG_PWM_TWL6030) += pwm-twl6030.o
obj-$(CONFIG_PWM_VT8500) += pwm-vt8500.o
139 changes: 139 additions & 0 deletions trunk/drivers/pwm/pwm-tipwmss.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* TI PWM Subsystem driver
*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
*/

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/err.h>
#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" },
{},
};
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) {
dev_err(&pdev->dev, "failed to allocate memory\n");
return -ENOMEM;
}

mutex_init(&info->pwmss_lock);

r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
dev_err(&pdev->dev, "no memory resource defined\n");
return -ENODEV;
}

info->mmio_base = devm_request_and_ioremap(&pdev->dev, r);
if (!info->mmio_base)
return -EADDRNOTAVAIL;

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);
if (ret)
dev_err(&pdev->dev, "no child node found\n");

return ret;
}

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;
}

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;
}

static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume);

static struct platform_driver pwmss_driver = {
.driver = {
.name = "pwmss",
.owner = THIS_MODULE,
.pm = &pwmss_pm_ops,
.of_match_table = pwmss_of_match,
},
.probe = pwmss_probe,
.remove = pwmss_remove,
};

module_platform_driver(pwmss_driver);

MODULE_DESCRIPTION("PWM Subsystem driver");
MODULE_AUTHOR("Texas Instruments");
MODULE_LICENSE("GPL");
39 changes: 39 additions & 0 deletions trunk/drivers/pwm/pwm-tipwmss.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* TI PWM Subsystem driver
*
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
*/

#ifndef __TIPWMSS_H
#define __TIPWMSS_H

#ifdef CONFIG_PWM_TIPWMSS
/* PWM substem clock gating */
#define PWMSS_ECAPCLK_EN BIT(0)
#define PWMSS_ECAPCLK_STOP_REQ BIT(1)
#define PWMSS_EPWMCLK_EN BIT(8)
#define PWMSS_EPWMCLK_STOP_REQ BIT(9)

#define PWMSS_ECAPCLK_EN_ACK BIT(0)
#define PWMSS_EPWMCLK_EN_ACK BIT(8)

extern u16 pwmss_submodule_state_change(struct device *dev, int set);
#else
static inline u16 pwmss_submodule_state_change(struct device *dev, int set)
{
/* return success status value */
return 0xFFFF;
}
#endif
#endif /* __TIPWMSS_H */

0 comments on commit 503fd52

Please sign in to comment.