|
求大神给下面的程序做注解,请稍详细些,谢谢。% R4 A" q) J {6 U/ A
#include <linux/init.h>5 F8 { J4 u- o2 t, ^: S. _
#include <linux/module.h>
$ L7 c4 k2 u) g# k' w#include <linux/kernel.h>
, W5 m; N2 a5 s: J1 ?- N#include <linux/types.h>/ N7 I6 X8 @# c- [; }9 c4 S
#include <linux/gpio.h>- R% j6 Y& [6 i- Y' e! a/ y
#include <linux/leds.h>1 ^; b- O9 m) m% y2 e& f1 X% T
#include <linux/platform_device.h>
$ b4 }% o; a1 u, w! j
2 A; Q- i. k) L2 e#include <asm/mach-types.h>
' e( X8 X! F; \# W#include <asm/mach/arch.h># k' y, S' K- r% v& s, n' N
#include <mach/da8xx.h>% \, x& @9 f9 ^: F( G6 r
#include <mach/mux.h>+ N" w {# T6 `* d" `
# \: N+ }6 Z# e4 E& s" H8 U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( `8 j$ P! ]8 V% {; Q ?( P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% Q0 w: d& i0 r0 j) F5 _: W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' n3 j8 g; P1 a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 q' B0 k+ z. [( d' n
# ]+ | _! E8 U6 [' Y$ [/* assign the tl som board LED-GPIOs*/
; T4 V7 D" W! t+ K* N6 ^7 pstatic const short da850_evm_tl_user_led_pins[] = {! s, g0 j5 v& g( q5 o8 d" D" j
/* These pins are definition at <mach/mux.h> file */( }- K9 |* K, r- s* i. ^# U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 v! G2 x/ b4 C% Z; Q; d! k! Z -1
% q' l: t$ a( g};
( o: s" O ~. z
: S7 H( {' A* V: }6 c k# ]9 xstatic struct gpio_led da850_evm_tl_leds[] = {4 P+ O/ ?3 ~& y: J& K
{( @0 F$ p2 W+ V
.active_low = 0,
% c! n' M$ _) ]! ~* g: D7 _ .gpio = DA850_USER_LED0,
& S8 ^% ~3 L+ u6 |% c9 t3 d' d .name = "user_led0",
g& d4 N9 H* e4 t( x1 n1 U .default_trigger = "default-on",5 ]) w& M. ^8 V5 f/ Q7 u6 f
},- a1 H2 i+ v' f( U* k! `
{
# t3 a; p5 ]8 R+ t .active_low = 0,
4 K3 Z e5 h5 x3 ~/ A0 S1 \$ U .gpio = DA850_USER_LED1,6 C K, C# H2 h# q4 R8 B$ ]
.name = "user_led1",7 O8 T* J* I9 m) C( @; `
.default_trigger = "default-on",
$ s: w) v- M! ^: _2 \ v },) z y: g9 z$ M. d) H8 b1 n0 V* p
{5 ~2 ?% d9 A( j( G+ w
.active_low = 0,
. K1 b( z, Q: _! _7 h/ |7 m/ ~2 L" ` .gpio = DA850_USER_LED2,# Y' h/ q% E8 M' I+ B2 |
.name = "user_led2",$ F- {% r3 b' D( N, j
.default_trigger = "default-on",
( \" q! f: e( `/ _% a# b1 F },
3 [& H g( Z$ }# P: e9 U {
2 O9 p D) n5 A) N .active_low = 0,% k! ^, N" [- J5 A9 A3 D; | f& g5 [
.gpio = DA850_USER_LED3,# ^2 g0 M! D' j3 n
.name = "user_led3",# n/ d6 i! O0 p# L3 w: H
.default_trigger = "default-on",9 W& q$ s, V4 K+ a
},: i: p- N; Y) \8 A2 N
};# p- g8 s7 {5 m8 G/ L+ Q9 z0 d
5 T( q0 i1 Z: K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& m) w5 u, Y: A T) X4 @+ U .leds = da850_evm_tl_leds,
8 c3 @5 Y( ?" [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, w6 o6 S% }/ E4 R
};( [1 V2 u! k4 e
; t2 r% G) R- y7 ^static void led_dev_release(struct device *dev)* p. \* z$ _+ i( m% Z
{
9 D$ A, {7 t& N6 u};
9 Z, U( V$ r: X' C! s0 _' k+ ^4 H9 {/ ^5 e+ j
static struct platform_device da850_evm_tl_leds_device = {
1 e& n5 h% f2 @! }6 u% t .name = "leds-gpio",+ t, y0 K5 {+ `) C3 l- v- D# a+ f
.id = 1,
N2 u0 j4 B3 ^8 u, }7 y7 O .dev = {
1 [* `2 b) H8 Y- G5 N .platform_data = &da850_evm_tl_leds_pdata,6 S9 S- J# q2 a' q4 u
.release = led_dev_release,
/ x3 R5 x2 r/ o, O) @) @ }
7 Y2 A1 b& ?) M};
* }! R* z0 g7 @; Y% F; D) ^2 J* u( ]' H8 V B
static int __init led_platform_init(void)
0 c$ j& G9 d: M$ h8 \* Y) q G{: M D" c4 F/ H: e& c
int ret;
5 D* u$ C r& _$ r7 ?8 X#if 0
% f6 U) p& G" t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); Z6 M. U9 n( D$ ?' Y! U; K
if (ret)7 W/ p- l9 U7 ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 D7 d" X% J/ \' q0 b! `6 R "%d\n", ret);
3 v% P" K5 y6 `#endif
. m6 K6 j& ~# B5 J5 M ret = platform_device_register(&da850_evm_tl_leds_device);
# Y$ X c* S- z& Y4 ^! O' G( g if (ret)
9 l9 k# q! ~2 y: J2 r pr_warning("Could not register som GPIO expander LEDS");( U; {. u# L, T: F# ]
else
( {: T1 I" D. r" Q3 ~ printk(KERN_INFO "LED register sucessful!\n");: K- n6 U2 v( }+ n
. x" s- T' m x0 ]* Z- O# [ return ret;" z: o& u3 Y2 U0 s. q3 u7 e
}4 d% o0 M# _6 p$ ]4 k. x6 O' b
: w6 l3 N2 o8 |3 _( y3 g
static void __exit led_platform_exit(void)
5 t2 Y G$ J/ ?- a; \: c' O{) M& z1 w/ W/ W$ R; t! o, T6 t+ G
platform_device_unregister(&da850_evm_tl_leds_device);1 t! }% {9 S! u; u8 M0 j
' E/ G4 V* K+ u$ B
printk(KERN_INFO "LED unregister!\n");( U; _, r9 V/ j# W8 `
}
2 ~/ l/ g. P& Q0 Z$ o1 G, L5 }- d& d; L u. J- H4 z3 a
module_init(led_platform_init);: V! ~9 U* E1 |0 ?4 L1 {9 U/ w
module_exit(led_platform_exit); S1 H! Y" `, N m. \ Y& o
/ p$ _8 I0 d& z9 e7 w
MODULE_DESCRIPTION("Led platform driver");0 n& y; U+ J, j v
MODULE_AUTHOR("Tronlong");+ V" d0 J* k6 ?; ^
MODULE_LICENSE("GPL");# ]6 y; ]+ R0 B& T
1 _9 J0 I. U' O) g3 L |
|