Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
bd268612
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
bd268612
编写于
7月 25, 2016
作者:
T
Thierry Reding
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'for-4.8/capture' into for-next
上级
489babea
1a366fe9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
77 addition
and
0 deletion
+77
-0
Documentation/ABI/testing/sysfs-class-pwm
Documentation/ABI/testing/sysfs-class-pwm
+9
-0
drivers/pwm/core.c
drivers/pwm/core.c
+27
-0
drivers/pwm/sysfs.c
drivers/pwm/sysfs.c
+17
-0
include/linux/pwm.h
include/linux/pwm.h
+24
-0
未找到文件。
Documentation/ABI/testing/sysfs-class-pwm
浏览文件 @
bd268612
...
...
@@ -77,3 +77,12 @@ Description:
Enable/disable the PWM signal.
0 is disabled
1 is enabled
What: /sys/class/pwm/pwmchipN/pwmX/capture
Date: June 2016
KernelVersion: 4.8
Contact: Lee Jones <lee.jones@linaro.org>
Description:
Capture information about a PWM signal. The output format is a
pair unsigned integers (period and duty cycle), separated by a
single space.
drivers/pwm/core.c
浏览文件 @
bd268612
...
...
@@ -525,6 +525,33 @@ int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state)
}
EXPORT_SYMBOL_GPL
(
pwm_apply_state
);
/**
* pwm_capture() - capture and report a PWM signal
* @pwm: PWM device
* @result: structure to fill with capture result
* @timeout: time to wait, in milliseconds, before giving up on capture
*
* Returns: 0 on success or a negative error code on failure.
*/
int
pwm_capture
(
struct
pwm_device
*
pwm
,
struct
pwm_capture
*
result
,
unsigned
long
timeout
)
{
int
err
;
if
(
!
pwm
||
!
pwm
->
chip
->
ops
)
return
-
EINVAL
;
if
(
!
pwm
->
chip
->
ops
->
capture
)
return
-
ENOSYS
;
mutex_lock
(
&
pwm_lock
);
err
=
pwm
->
chip
->
ops
->
capture
(
pwm
->
chip
,
pwm
,
result
,
timeout
);
mutex_unlock
(
&
pwm_lock
);
return
err
;
}
EXPORT_SYMBOL_GPL
(
pwm_capture
);
/**
* pwm_adjust_config() - adjust the current PWM config to the PWM arguments
* @pwm: PWM device
...
...
drivers/pwm/sysfs.c
浏览文件 @
bd268612
...
...
@@ -208,16 +208,33 @@ static ssize_t polarity_store(struct device *child,
return
ret
?
:
size
;
}
static
ssize_t
capture_show
(
struct
device
*
child
,
struct
device_attribute
*
attr
,
char
*
buf
)
{
struct
pwm_device
*
pwm
=
child_to_pwm_device
(
child
);
struct
pwm_capture
result
;
int
ret
;
ret
=
pwm_capture
(
pwm
,
&
result
,
jiffies_to_msecs
(
HZ
));
if
(
ret
)
return
ret
;
return
sprintf
(
buf
,
"%u %u
\n
"
,
result
.
period
,
result
.
duty_cycle
);
}
static
DEVICE_ATTR_RW
(
period
);
static
DEVICE_ATTR_RW
(
duty_cycle
);
static
DEVICE_ATTR_RW
(
enable
);
static
DEVICE_ATTR_RW
(
polarity
);
static
DEVICE_ATTR_RO
(
capture
);
static
struct
attribute
*
pwm_attrs
[]
=
{
&
dev_attr_period
.
attr
,
&
dev_attr_duty_cycle
.
attr
,
&
dev_attr_enable
.
attr
,
&
dev_attr_polarity
.
attr
,
&
dev_attr_capture
.
attr
,
NULL
};
ATTRIBUTE_GROUPS
(
pwm
);
...
...
include/linux/pwm.h
浏览文件 @
bd268612
...
...
@@ -5,7 +5,9 @@
#include <linux/mutex.h>
#include <linux/of.h>
struct
pwm_capture
;
struct
seq_file
;
struct
pwm_chip
;
/**
...
...
@@ -241,6 +243,7 @@ pwm_set_relative_duty_cycle(struct pwm_state *state, unsigned int duty_cycle,
* @free: optional hook for freeing a PWM
* @config: configure duty cycles and period length for this PWM
* @set_polarity: configure the polarity of this PWM
* @capture: capture and report PWM signal
* @enable: enable PWM output toggling
* @disable: disable PWM output toggling
* @apply: atomically apply a new PWM config. The state argument
...
...
@@ -260,6 +263,8 @@ struct pwm_ops {
int
duty_ns
,
int
period_ns
);
int
(
*
set_polarity
)(
struct
pwm_chip
*
chip
,
struct
pwm_device
*
pwm
,
enum
pwm_polarity
polarity
);
int
(
*
capture
)(
struct
pwm_chip
*
chip
,
struct
pwm_device
*
pwm
,
struct
pwm_capture
*
result
,
unsigned
long
timeout
);
int
(
*
enable
)(
struct
pwm_chip
*
chip
,
struct
pwm_device
*
pwm
);
void
(
*
disable
)(
struct
pwm_chip
*
chip
,
struct
pwm_device
*
pwm
);
int
(
*
apply
)(
struct
pwm_chip
*
chip
,
struct
pwm_device
*
pwm
,
...
...
@@ -300,6 +305,16 @@ struct pwm_chip {
bool
can_sleep
;
};
/**
* struct pwm_capture - PWM capture data
* @period: period of the PWM signal (in nanoseconds)
* @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
*/
struct
pwm_capture
{
unsigned
int
period
;
unsigned
int
duty_cycle
;
};
#if IS_ENABLED(CONFIG_PWM)
/* PWM user APIs */
struct
pwm_device
*
pwm_request
(
int
pwm_id
,
const
char
*
label
);
...
...
@@ -412,6 +427,8 @@ static inline void pwm_disable(struct pwm_device *pwm)
}
/* PWM provider APIs */
int
pwm_capture
(
struct
pwm_device
*
pwm
,
struct
pwm_capture
*
result
,
unsigned
long
timeout
);
int
pwm_set_chip_data
(
struct
pwm_device
*
pwm
,
void
*
data
);
void
*
pwm_get_chip_data
(
struct
pwm_device
*
pwm
);
...
...
@@ -463,6 +480,13 @@ static inline int pwm_config(struct pwm_device *pwm, int duty_ns,
return
-
EINVAL
;
}
static
inline
int
pwm_capture
(
struct
pwm_device
*
pwm
,
struct
pwm_capture
*
result
,
unsigned
long
timeout
)
{
return
-
EINVAL
;
}
static
inline
int
pwm_set_polarity
(
struct
pwm_device
*
pwm
,
enum
pwm_polarity
polarity
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录