|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* I h( }4 m9 x: _
#include <linux/init.h>
7 ?# p- o' m! g# m#include <linux/module.h>8 v4 k+ {3 `$ ~( z4 ^- O
#include <linux/kernel.h>" Q3 a q* x3 ?- \) K+ p- s S
#include <linux/types.h>
# ^6 T% {7 T- K6 U' o1 _#include <linux/gpio.h>: v. Q. T, x4 n) d( l
#include <linux/leds.h>, A9 w( H( G' o" d8 f( K) \# I& F
#include <linux/platform_device.h>
9 g; P2 Z- G) R9 u' t- s
# L& k# }2 Q1 D% [' x/ l; I/ h#include <asm/mach-types.h>
8 v6 o' C1 H" d# O#include <asm/mach/arch.h>
0 }8 h1 S/ }: d8 n& h% J#include <mach/da8xx.h>
+ C) Q, Y- I" g7 i3 E#include <mach/mux.h>
: u& _ V; O7 m% ?# d+ F, h# P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ h' N6 Q4 [0 @( {; m' l h) o
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" o) F0 z7 E; n4 L2 W% i9 U) X9 |#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* v3 Q" }% Q9 R4 l9 A& C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( h4 h3 p0 V; b) q5 _5 \( \" V9 H& j' q: B/ [, t! a" `
/* assign the tl som board LED-GPIOs*/
9 P" [( H* X$ \( |, A( S# y+ pstatic const short da850_evm_tl_user_led_pins[] = {5 B* B5 v6 F/ ?: c
/* These pins are definition at <mach/mux.h> file */
: p+ t1 R. G. Y a# }- R6 U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! q2 H3 t1 L+ `) m -1
; I0 B5 }5 M1 K( ^; K3 n9 G$ U! \};1 `6 c% ~0 Z! E+ W& O P @5 X8 B6 C" B
& m+ q" k7 X7 b6 v$ I; D# Mstatic struct gpio_led da850_evm_tl_leds[] = {$ ^! f' m, w) ]5 V
{- T" U1 b$ |( W8 L q# e& i5 n1 l- _
.active_low = 0,0 A C$ h( T; Z
.gpio = DA850_USER_LED0,
6 g$ @5 ^9 ]/ N+ D# _6 j1 z .name = "user_led0",
- K/ L7 _# K8 q .default_trigger = "default-on",
* M& N# R# h" {, Z! Y! | },
# y) B7 T# I& T H4 i, a+ B {; l8 ~8 V( l* H i
.active_low = 0,
0 Z% G! Z2 s4 n# ? .gpio = DA850_USER_LED1,8 Z) o% n7 G) Z: M( A
.name = "user_led1",; w. J6 y& x+ y' R5 t6 i
.default_trigger = "default-on",. s, A7 ]& b- h% b7 F8 i8 G0 @0 P3 @0 o
},
( k" o7 q" Y& M9 a3 g+ u {
/ X) e& M! @1 n, P& w9 t' q .active_low = 0,
; y7 x, q. _% }9 H- D! c .gpio = DA850_USER_LED2,
! {7 k7 {8 p6 D5 g' I& N7 H0 Z .name = "user_led2",# I( P! J' s, k: n9 |: ~
.default_trigger = "default-on",
" m0 d& S, a/ Y( O4 J3 E },
; E0 q8 a( S! K2 [6 V {9 H* m) p9 j2 `# @- \* t6 M
.active_low = 0,1 r7 p# s0 O3 J: N
.gpio = DA850_USER_LED3,
, b: t- H: i& Z! X& m6 k- D .name = "user_led3",2 l) S! n5 i8 B7 U- I
.default_trigger = "default-on",
- ~$ d& `, L! F! q( f V },
: B: c7 Y+ X: {% ?% F2 j: P; Y};8 W: k3 B8 ~5 q7 \" x3 D& Z
4 M/ r7 b T, A# Z! T
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' f- [" _8 ~8 F* w
.leds = da850_evm_tl_leds,
0 ~( E, T5 c) d3 L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ D* N$ N$ O _' |3 g$ R$ ~2 U5 k- [7 A};3 u% m" C$ k& Q. Y1 e4 \# _- w
8 {3 H: z5 ]# L* ?9 ?! c! l
static void led_dev_release(struct device *dev)
2 A# _+ f w# S" m3 Q{
' H1 q7 d! R3 v( ^7 G};
" u# }+ Q a9 ^
! J1 [/ V; ]+ }; h3 q5 ustatic struct platform_device da850_evm_tl_leds_device = {
# a: a0 m5 C& S- ~( ^# w .name = "leds-gpio",. O! q' g6 k8 L+ F4 w! ~9 O3 }) V0 j9 n
.id = 1,% Z9 |# A! N" U: W$ H
.dev = {
/ B- |( S0 u' H; t U .platform_data = &da850_evm_tl_leds_pdata,
/ q/ o# c7 S# `% F* \/ \3 z- K3 ` .release = led_dev_release,/ s8 X; E; J6 y3 C( Q @
}
7 t' C# ?& {, j1 {};/ @8 s5 q0 C) v/ b
6 r# t' h) n7 ^6 o2 q& J4 Q) c7 j
static int __init led_platform_init(void)3 c z! b! Z l! l& E: C
{+ b3 A# K; \' U- |; b' F
int ret;
3 h! Q: h3 c0 t e2 m/ y#if 0. ]8 ~ }. Z. X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; ?2 t4 h9 e1 l# ~: r3 T$ o5 M0 V
if (ret)! U2 y' w+ C- T& G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 R0 `* _$ \& G& l
"%d\n", ret);
$ k. e6 \+ ?+ F% d, j# F2 q#endif
2 l& @6 q6 _2 e/ t ret = platform_device_register(&da850_evm_tl_leds_device);: R- \5 E* ~: f# n6 h; d. _& z
if (ret)
0 G q# p7 w0 x( N; s1 a pr_warning("Could not register som GPIO expander LEDS");% R5 X- T" j9 ^
else
4 P7 F* E( [' H printk(KERN_INFO "LED register sucessful!\n");
* H Z+ z& j1 A! W( O# P4 Z& h
1 e- I* ~# c6 Z5 Q8 F2 F0 D# } d+ ~ return ret;$ D0 \$ L. V+ E2 P: L9 G
}8 Q& [8 V) ?2 e/ f" E0 C" Q" R
3 S+ ?$ z& U+ ?+ Q% p
static void __exit led_platform_exit(void). M1 d8 y9 T# b; _ b
{1 B- R9 i+ P4 g6 S. I0 v
platform_device_unregister(&da850_evm_tl_leds_device);) Y6 [" G0 Z* [4 s: I9 n' {+ C
( a( P9 A& D+ M8 h
printk(KERN_INFO "LED unregister!\n");
8 b9 Y; d9 S2 l$ r6 _! E2 {}
$ v8 U# o+ I* k/ \ \: L' g* @9 H2 c
module_init(led_platform_init);3 ?* b0 z' K% |
module_exit(led_platform_exit);* x8 p! g. M2 T, ~' \
p+ @" D) t+ I7 V; ]7 W& HMODULE_DESCRIPTION("Led platform driver");3 S0 l0 A5 m/ b+ P: B4 z7 C
MODULE_AUTHOR("Tronlong");' m( c4 c6 ^$ r4 \3 G0 r/ E
MODULE_LICENSE("GPL");4 u, e# J8 y7 s
7 k# m+ h9 e1 A7 q; o8 J |
|