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
3d2a98cd
Commit
3d2a98cd
authored
Apr 13, 2009
by
Eric Miao
Committed by
Eric Miao
Jun 05, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ARM] pxa: simplify secondary PWM handling and use platform_device_id table
Signed-off-by:
Eric Miao
<
eric.miao@marvell.com
>
parent
1a77920e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
67 deletions
+49
-67
arch/arm/mach-pxa/pwm.c
arch/arm/mach-pxa/pwm.c
+49
-67
No files found.
arch/arm/mach-pxa/pwm.c
View file @
3d2a98cd
...
...
@@ -21,6 +21,16 @@
#include <asm/div64.h>
#define HAS_SECONDARY_PWM 0x10
static
const
struct
platform_device_id
pwm_id_table
[]
=
{
/* PWM has_secondary_pwm? */
{
"pxa25x-pwm"
,
0
},
{
"pxa27x-pwm"
,
HAS_SECONDARY_PWM
},
{
},
};
MODULE_DEVICE_TABLE
(
platform
,
pwm_id_table
);
/* PWM registers and bits definitions */
#define PWMCR (0x00)
#define PWMDCR (0x04)
...
...
@@ -31,6 +41,7 @@
struct
pwm_device
{
struct
list_head
node
;
struct
pwm_device
*
secondary
;
struct
platform_device
*
pdev
;
const
char
*
label
;
...
...
@@ -159,17 +170,17 @@ static inline void __add_pwm(struct pwm_device *pwm)
mutex_unlock
(
&
pwm_lock
);
}
static
struct
pwm_device
*
pwm_probe
(
struct
platform_device
*
pdev
,
unsigned
int
pwm_id
,
struct
pwm_device
*
parent_pwm
)
static
int
__devinit
pwm_probe
(
struct
platform_device
*
pdev
)
{
struct
pwm_device
*
pwm
;
struct
platform_device_id
*
id
=
platform_get_device_id
(
pdev
);
struct
pwm_device
*
pwm
,
*
secondary
=
NULL
;
struct
resource
*
r
;
int
ret
=
0
;
pwm
=
kzalloc
(
sizeof
(
struct
pwm_device
),
GFP_KERNEL
);
if
(
pwm
==
NULL
)
{
dev_err
(
&
pdev
->
dev
,
"failed to allocate memory
\n
"
);
return
ERR_PTR
(
-
ENOMEM
)
;
return
-
ENOMEM
;
}
pwm
->
clk
=
clk_get
(
&
pdev
->
dev
,
NULL
);
...
...
@@ -180,16 +191,9 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
pwm
->
clk_enabled
=
0
;
pwm
->
use_count
=
0
;
pwm
->
pwm_id
=
p
wm_
id
;
pwm
->
pwm_id
=
p
dev
->
id
;
pwm
->
pdev
=
pdev
;
if
(
parent_pwm
!=
NULL
)
{
/* registers for the second PWM has offset of 0x10 */
pwm
->
mmio_base
=
parent_pwm
->
mmio_base
+
0x10
;
__add_pwm
(
pwm
);
return
pwm
;
}
r
=
platform_get_resource
(
pdev
,
IORESOURCE_MEM
,
0
);
if
(
r
==
NULL
)
{
dev_err
(
&
pdev
->
dev
,
"no memory resource defined
\n
"
);
...
...
@@ -211,9 +215,27 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
goto
err_free_mem
;
}
if
(
id
->
driver_data
&
HAS_SECONDARY_PWM
)
{
secondary
=
kzalloc
(
sizeof
(
struct
pwm_device
),
GFP_KERNEL
);
if
(
secondary
==
NULL
)
{
ret
=
-
ENOMEM
;
goto
err_free_mem
;
}
*
secondary
=
*
pwm
;
pwm
->
secondary
=
secondary
;
/* registers for the second PWM has offset of 0x10 */
secondary
->
mmio_base
=
pwm
->
mmio_base
+
0x10
;
secondary
->
pwm_id
=
pdev
->
id
+
2
;
}
__add_pwm
(
pwm
);
if
(
secondary
)
__add_pwm
(
secondary
);
platform_set_drvdata
(
pdev
,
pwm
);
return
pwm
;
return
0
;
err_free_mem:
release_mem_region
(
r
->
start
,
r
->
end
-
r
->
start
+
1
);
...
...
@@ -221,32 +243,7 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
clk_put
(
pwm
->
clk
);
err_free:
kfree
(
pwm
);
return
ERR_PTR
(
ret
);
}
static
int
__devinit
pxa25x_pwm_probe
(
struct
platform_device
*
pdev
)
{
struct
pwm_device
*
pwm
=
pwm_probe
(
pdev
,
pdev
->
id
,
NULL
);
if
(
IS_ERR
(
pwm
))
return
PTR_ERR
(
pwm
);
return
0
;
}
static
int
__devinit
pxa27x_pwm_probe
(
struct
platform_device
*
pdev
)
{
struct
pwm_device
*
pwm
;
pwm
=
pwm_probe
(
pdev
,
pdev
->
id
,
NULL
);
if
(
IS_ERR
(
pwm
))
return
PTR_ERR
(
pwm
);
pwm
=
pwm_probe
(
pdev
,
pdev
->
id
+
2
,
pwm
);
if
(
IS_ERR
(
pwm
))
return
PTR_ERR
(
pwm
);
return
0
;
return
ret
;
}
static
int
__devexit
pwm_remove
(
struct
platform_device
*
pdev
)
...
...
@@ -259,6 +256,12 @@ static int __devexit pwm_remove(struct platform_device *pdev)
return
-
ENODEV
;
mutex_lock
(
&
pwm_lock
);
if
(
pwm
->
secondary
)
{
list_del
(
&
pwm
->
secondary
->
node
);
kfree
(
pwm
->
secondary
);
}
list_del
(
&
pwm
->
node
);
mutex_unlock
(
&
pwm_lock
);
...
...
@@ -272,46 +275,25 @@ static int __devexit pwm_remove(struct platform_device *pdev)
return
0
;
}
static
struct
platform_driver
p
xa25x_p
wm_driver
=
{
static
struct
platform_driver
pwm_driver
=
{
.
driver
=
{
.
name
=
"pxa25x-pwm"
,
.
owner
=
THIS_MODULE
,
},
.
probe
=
pxa25x_pwm_probe
,
.
remove
=
__devexit_p
(
pwm_remove
),
};
static
struct
platform_driver
pxa27x_pwm_driver
=
{
.
driver
=
{
.
name
=
"pxa27x-pwm"
,
},
.
probe
=
pxa27x_pwm_probe
,
.
probe
=
pwm_probe
,
.
remove
=
__devexit_p
(
pwm_remove
),
.
id_table
=
pwm_id_table
,
};
static
int
__init
pwm_init
(
void
)
{
int
ret
=
0
;
ret
=
platform_driver_register
(
&
pxa25x_pwm_driver
);
if
(
ret
)
{
printk
(
KERN_ERR
"failed to register pxa25x_pwm_driver
\n
"
);
return
ret
;
}
ret
=
platform_driver_register
(
&
pxa27x_pwm_driver
);
if
(
ret
)
{
printk
(
KERN_ERR
"failed to register pxa27x_pwm_driver
\n
"
);
return
ret
;
}
return
ret
;
return
platform_driver_register
(
&
pwm_driver
);
}
arch_initcall
(
pwm_init
);
static
void
__exit
pwm_exit
(
void
)
{
platform_driver_unregister
(
&
pxa25x_pwm_driver
);
platform_driver_unregister
(
&
pxa27x_pwm_driver
);
platform_driver_unregister
(
&
pwm_driver
);
}
module_exit
(
pwm_exit
);
...
...
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