|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: s( ?0 {5 B3 S
#include <linux/init.h>
3 R$ Q5 R! }) P% b4 W" `#include <linux/module.h>7 Z7 U; w/ z( A
#include <linux/kernel.h> N9 C; v' U; ~6 @! n5 L" V* U
#include <linux/types.h>: N) B3 j8 o' T3 P) n
#include <linux/gpio.h>" [; @4 a% l/ I* p& V
#include <linux/leds.h>
% H' N$ Y. f" t; l+ d4 I" S" D#include <linux/platform_device.h>
7 n C+ \8 ]: W* W- b9 g2 ?% W8 s9 g/ ~3 T( q9 v
#include <asm/mach-types.h>2 ~, ]4 K# I! @1 I4 f
#include <asm/mach/arch.h>
+ m8 H1 U2 ?$ x$ x6 B$ ?8 T#include <mach/da8xx.h>
. A/ g( Y: {% b3 F+ R( V#include <mach/mux.h>; n% H- V2 M: u8 L3 @8 D
3 H( `# d) r! j- M2 T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% l$ M" k& W' ]7 h* q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 c) j2 \1 |) y' y7 P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, j* r, x9 s1 a" X* A+ V5 d+ F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% K- q5 I& m. }8 o; |+ `5 i
V" ^/ X, X8 b/* assign the tl som board LED-GPIOs*/
2 _7 g! R# Q0 N- Xstatic const short da850_evm_tl_user_led_pins[] = {+ x3 @* e0 h" ^3 h1 P$ _ B6 B
/* These pins are definition at <mach/mux.h> file */
" G# }/ T0 z- @: ^; _$ N6 _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& R/ U5 R6 x- P6 d# O -15 u7 ?5 i$ y5 |: h( c$ m% u* e, W
};5 J8 i1 K: v& ]" j# g1 b0 |; \* p
! y2 W+ R0 a, H! J" e4 w7 m E' z
static struct gpio_led da850_evm_tl_leds[] = {
1 Q6 F$ H M' d% d; F {
3 w' b) {; W* @! Y# O$ ^7 Z+ G .active_low = 0,
4 [ z) h% T* d+ t2 ` .gpio = DA850_USER_LED0,
9 H2 b9 i; N% J3 J7 Y7 l .name = "user_led0",% G6 Y9 a. I, W: y# E4 ^7 h3 R
.default_trigger = "default-on",
, Y1 o' n$ c1 j( u" G9 { },2 G: q2 I4 ^1 C% B3 Y' c
{+ k: ] `$ c# f
.active_low = 0,
L7 Z$ f4 }4 k7 X" k .gpio = DA850_USER_LED1,$ b- ~8 I- o7 h) z
.name = "user_led1",
7 H, ^9 S& [1 y8 z .default_trigger = "default-on",4 E' J2 a, n% C( u0 y. v
},
+ W }5 q! P1 B# W6 o {
2 u6 \: Y n, |( Y .active_low = 0,% ]9 I( X n0 n) S d# ]# n
.gpio = DA850_USER_LED2,
- l4 b+ x' V3 j! Q# i .name = "user_led2",* y( Z5 w: Y/ h0 i
.default_trigger = "default-on",
5 T& y* G* O) E! |, ` },
/ H: }) H) p3 }; W+ l: T3 P$ e; W3 c {) a' ^! j% L& R
.active_low = 0,
6 c% D7 ?9 ]0 b- h( H% K" ^ .gpio = DA850_USER_LED3,8 r2 J4 A; b$ v5 T
.name = "user_led3",
2 n- W& `; g7 b. }, u& M .default_trigger = "default-on",
4 e; k J3 r5 `5 U/ L },3 r: S8 N$ s7 |1 S( R' ?) g9 S
};) L9 l0 W4 ?+ C
. [" _' p/ z2 I: mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. Y: @ v* t' w/ L% N- L. e .leds = da850_evm_tl_leds, F( b) i( _# T" l/ X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
W- F) T, t" t/ R};
" |+ I9 s% J8 {7 f& d2 r: U/ s/ q4 j1 O$ w5 q# P
static void led_dev_release(struct device *dev)( N. @6 ]1 @ @7 G* C8 k1 ~
{( M7 O( Z1 V C) D' B5 `) }
};) _. Q, B( b! Y& y, k; o( q
2 @6 Y/ s5 O0 H% Y" Istatic struct platform_device da850_evm_tl_leds_device = {8 _2 X1 t8 A- ]$ F: X
.name = "leds-gpio",
3 L" Q; g- T% e .id = 1,* [$ P; B. ]4 k! e d
.dev = {
6 L% a1 g3 T+ x' ], g .platform_data = &da850_evm_tl_leds_pdata,8 j% `- ^7 A) ^7 ?
.release = led_dev_release,4 b( Y$ _) b0 M* Z B' I6 S
}
0 {/ |; K1 B( R: G6 Y0 e};8 W7 d2 ]1 D# h. e8 c E
9 I( `) K# t9 M8 w# q. rstatic int __init led_platform_init(void)
% ^& @# a9 \# w% V& C{
! R/ H& A4 J& j) h int ret;
( l3 N$ t0 `6 f7 c" G% T/ V3 O#if 0
: B3 E; d% \) W# J, h* O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% k! V: K: d p8 `% z! @
if (ret) q c# Q& `+ V, X( ?0 ~) u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) C- }5 A# ]* {$ k. d. p "%d\n", ret);6 p/ K3 k7 Z- P
#endif: ~( o# P6 D8 G& J k$ W
ret = platform_device_register(&da850_evm_tl_leds_device);+ P" J+ G' {( w0 e w$ @
if (ret)
" k" g# P1 M6 x4 B4 ^) \6 M( _ pr_warning("Could not register som GPIO expander LEDS");
8 N) ]( J ]+ w else
: p% E9 z$ Y! l printk(KERN_INFO "LED register sucessful!\n");- D! f5 Y* L4 \# @; k2 `0 `
4 b* v% r+ }* w' E2 n" `" w- l
return ret;
+ S9 u1 I; H% r3 h, X( _9 p5 x}/ m( C' ^: ~- J: a1 t- n
6 m/ e+ e8 P" n/ D& {% s; E# hstatic void __exit led_platform_exit(void)8 T0 q. [9 W5 q
{
# i8 |% t/ ^* K8 B8 G, i8 A platform_device_unregister(&da850_evm_tl_leds_device);
, k2 O* P9 T% ^6 r" _" A8 O. i7 ]4 t! G9 m
printk(KERN_INFO "LED unregister!\n");9 C8 A9 L5 X5 J% v6 v. L2 k# Z
}
. ~# f9 A, D" l& L8 D
% e+ m8 A$ T7 C9 G# V+ Ymodule_init(led_platform_init);& {- b7 I0 I9 i6 ~
module_exit(led_platform_exit);# ~: N4 L& [7 f( X* H" C
6 i: D2 p9 J4 I% D0 ?5 d+ hMODULE_DESCRIPTION("Led platform driver");
. S7 E+ r& y! y4 e! U/ iMODULE_AUTHOR("Tronlong");8 {/ n$ ^7 \% Q+ T! ?
MODULE_LICENSE("GPL");
/ U1 e8 M% V+ @: o9 L) ~) F x/ E6 J9 ~6 j0 O
|
|