Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
3f1f368e
Commit
3f1f368e
authored
May 17, 2016
by
Thierry Reding
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'for-4.7/pwm-args' into for-4.7/pwm-atomic
parents
f55532a0
fbd45a12
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
8 deletions
+55
-8
drivers/pwm/core.c
drivers/pwm/core.c
+20
-6
drivers/pwm/pwm-clps711x.c
drivers/pwm/pwm-clps711x.c
+1
-1
drivers/pwm/pwm-pxa.c
drivers/pwm/pwm-pxa.c
+1
-1
include/linux/pwm.h
include/linux/pwm.h
+33
-0
No files found.
drivers/pwm/core.c
View file @
3f1f368e
...
@@ -146,12 +146,12 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
...
@@ -146,12 +146,12 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
if
(
IS_ERR
(
pwm
))
if
(
IS_ERR
(
pwm
))
return
pwm
;
return
pwm
;
pwm
_set_period
(
pwm
,
args
->
args
[
1
])
;
pwm
->
args
.
period
=
args
->
args
[
1
]
;
if
(
args
->
args
[
2
]
&
PWM_POLARITY_INVERTED
)
if
(
args
->
args
[
2
]
&
PWM_POLARITY_INVERTED
)
pwm
_set_polarity
(
pwm
,
PWM_POLARITY_INVERSED
)
;
pwm
->
args
.
polarity
=
PWM_POLARITY_INVERSED
;
else
else
pwm
_set_polarity
(
pwm
,
PWM_POLARITY_NORMAL
)
;
pwm
->
args
.
polarity
=
PWM_POLARITY_NORMAL
;
return
pwm
;
return
pwm
;
}
}
...
@@ -172,7 +172,7 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
...
@@ -172,7 +172,7 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
if
(
IS_ERR
(
pwm
))
if
(
IS_ERR
(
pwm
))
return
pwm
;
return
pwm
;
pwm
_set_period
(
pwm
,
args
->
args
[
1
])
;
pwm
->
args
.
period
=
args
->
args
[
1
]
;
return
pwm
;
return
pwm
;
}
}
...
@@ -620,6 +620,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
...
@@ -620,6 +620,13 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
pwm
->
label
=
con_id
;
pwm
->
label
=
con_id
;
/*
* FIXME: This should be removed once all PWM users properly make use
* of struct pwm_args to initialize the PWM device. As long as this is
* here, the PWM state and hardware state can get out of sync.
*/
pwm_apply_args
(
pwm
);
put:
put:
of_node_put
(
args
.
np
);
of_node_put
(
args
.
np
);
...
@@ -751,8 +758,15 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
...
@@ -751,8 +758,15 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
if
(
IS_ERR
(
pwm
))
if
(
IS_ERR
(
pwm
))
goto
out
;
goto
out
;
pwm_set_period
(
pwm
,
chosen
->
period
);
pwm
->
args
.
period
=
chosen
->
period
;
pwm_set_polarity
(
pwm
,
chosen
->
polarity
);
pwm
->
args
.
polarity
=
chosen
->
polarity
;
/*
* FIXME: This should be removed once all PWM users properly make use
* of struct pwm_args to initialize the PWM device. As long as this is
* here, the PWM state and hardware state can get out of sync.
*/
pwm_apply_args
(
pwm
);
out:
out:
mutex_unlock
(
&
pwm_lookup_lock
);
mutex_unlock
(
&
pwm_lookup_lock
);
...
...
drivers/pwm/pwm-clps711x.c
View file @
3f1f368e
...
@@ -60,7 +60,7 @@ static int clps711x_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
...
@@ -60,7 +60,7 @@ static int clps711x_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
return
-
EINVAL
;
return
-
EINVAL
;
/* Store constant period value */
/* Store constant period value */
pwm
_set_period
(
pwm
,
DIV_ROUND_CLOSEST
(
NSEC_PER_SEC
,
freq
)
);
pwm
->
args
.
period
=
DIV_ROUND_CLOSEST
(
NSEC_PER_SEC
,
freq
);
return
0
;
return
0
;
}
}
...
...
drivers/pwm/pwm-pxa.c
View file @
3f1f368e
...
@@ -160,7 +160,7 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
...
@@ -160,7 +160,7 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
if
(
IS_ERR
(
pwm
))
if
(
IS_ERR
(
pwm
))
return
pwm
;
return
pwm
;
pwm
_set_period
(
pwm
,
args
->
args
[
0
])
;
pwm
->
args
.
period
=
args
->
args
[
0
]
;
return
pwm
;
return
pwm
;
}
}
...
...
include/linux/pwm.h
View file @
3f1f368e
...
@@ -74,6 +74,24 @@ enum pwm_polarity {
...
@@ -74,6 +74,24 @@ enum pwm_polarity {
PWM_POLARITY_INVERSED
,
PWM_POLARITY_INVERSED
,
};
};
/**
* struct pwm_args - board-dependent PWM arguments
* @period: reference period
* @polarity: reference polarity
*
* This structure describes board-dependent arguments attached to a PWM
* device. These arguments are usually retrieved from the PWM lookup table or
* device tree.
*
* Do not confuse this with the PWM state: PWM arguments represent the initial
* configuration that users want to use on this PWM device rather than the
* current PWM hardware state.
*/
struct
pwm_args
{
unsigned
int
period
;
enum
pwm_polarity
polarity
;
};
enum
{
enum
{
PWMF_REQUESTED
=
1
<<
0
,
PWMF_REQUESTED
=
1
<<
0
,
PWMF_ENABLED
=
1
<<
1
,
PWMF_ENABLED
=
1
<<
1
,
...
@@ -92,6 +110,7 @@ enum {
...
@@ -92,6 +110,7 @@ enum {
* @period: period of the PWM signal (in nanoseconds)
* @period: period of the PWM signal (in nanoseconds)
* @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
* @duty_cycle: duty cycle of the PWM signal (in nanoseconds)
* @polarity: polarity of the PWM signal
* @polarity: polarity of the PWM signal
* @args: PWM arguments
*/
*/
struct
pwm_device
{
struct
pwm_device
{
const
char
*
label
;
const
char
*
label
;
...
@@ -105,6 +124,8 @@ struct pwm_device {
...
@@ -105,6 +124,8 @@ struct pwm_device {
unsigned
int
period
;
unsigned
int
period
;
unsigned
int
duty_cycle
;
unsigned
int
duty_cycle
;
enum
pwm_polarity
polarity
;
enum
pwm_polarity
polarity
;
struct
pwm_args
args
;
};
};
static
inline
bool
pwm_is_enabled
(
const
struct
pwm_device
*
pwm
)
static
inline
bool
pwm_is_enabled
(
const
struct
pwm_device
*
pwm
)
...
@@ -144,6 +165,18 @@ static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm)
...
@@ -144,6 +165,18 @@ static inline enum pwm_polarity pwm_get_polarity(const struct pwm_device *pwm)
return
pwm
?
pwm
->
polarity
:
PWM_POLARITY_NORMAL
;
return
pwm
?
pwm
->
polarity
:
PWM_POLARITY_NORMAL
;
}
}
static
inline
void
pwm_get_args
(
const
struct
pwm_device
*
pwm
,
struct
pwm_args
*
args
)
{
*
args
=
pwm
->
args
;
}
static
inline
void
pwm_apply_args
(
struct
pwm_device
*
pwm
)
{
pwm_set_period
(
pwm
,
pwm
->
args
.
period
);
pwm_set_polarity
(
pwm
,
pwm
->
args
.
polarity
);
}
/**
/**
* struct pwm_ops - PWM controller operations
* struct pwm_ops - PWM controller operations
* @request: optional hook for requesting a PWM
* @request: optional hook for requesting a PWM
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment