|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. b8 E! n8 |: p! A7 H#include <linux/init.h>+ u+ N/ n$ z- X9 {6 t, l9 A
#include <linux/module.h>3 ^% j" _" O' N0 h4 r. h
#include <linux/kernel.h>+ C; t% o2 W7 o/ [& E; }
#include <linux/types.h>( a5 f3 o5 R K+ n/ H0 z5 f6 M( b
#include <linux/gpio.h>
/ \% u1 L5 l6 U#include <linux/leds.h>
. |5 D+ r- d# G3 r5 M/ Z" I#include <linux/platform_device.h>
1 L: m3 _' H5 D' u- X O* l: |8 ?6 Q1 g3 T
#include <asm/mach-types.h>
; \* s9 J5 j2 f3 F; m- L. {#include <asm/mach/arch.h>
1 V( k( b! G' J) O8 v3 v/ M#include <mach/da8xx.h>3 h# {( t0 w# k9 D
#include <mach/mux.h>3 Y6 ^# G$ k7 f( C7 d1 j! ]
6 S$ }2 P# y+ G- w) |& m& K( S6 c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 E2 E# {" o' b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 M3 s/ s# K) r+ f" ^) H8 @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: V% c) p9 h: a4 i* r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" j" K, ]" K0 P' @( M- Z1 p E+ p, i, X% U" A
/* assign the tl som board LED-GPIOs*/
) P' K9 C. b. Lstatic const short da850_evm_tl_user_led_pins[] = {* t/ x( v6 m& t% K! f# e
/* These pins are definition at <mach/mux.h> file */
1 R! E: |- q( F2 S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 m0 i& {5 ?' K: a
-1* ?8 D, g) x& L, R Z; K! ]4 f
};* J; }+ B3 h9 ?: U2 }
3 p' H7 X$ `0 H; C
static struct gpio_led da850_evm_tl_leds[] = {9 x! [" ^8 c& W% P: @
{+ T% c4 d: ]7 E: x3 [5 g" Q
.active_low = 0,+ S4 j; I& u9 B6 U/ F
.gpio = DA850_USER_LED0,
m* j' @; A8 }/ F# {. \. e .name = "user_led0",( x0 p; k( P" _6 B
.default_trigger = "default-on",
, ?$ l# g W1 d% a$ f6 H },# R* [- q9 H) {" j1 I8 m
{" x7 ~' F6 c+ p+ }- Y, p4 i) S) J
.active_low = 0,
! P' Y. k% y0 p5 |, L1 @ .gpio = DA850_USER_LED1,
, H. t0 R! c) H' C/ _. M .name = "user_led1",
8 H' o! |" ^1 M! a$ u .default_trigger = "default-on",. X6 D# g( d3 j& d0 d3 |
},+ ~4 @) [! |$ k( |. D
{$ V9 h/ z, i' E) G# ]
.active_low = 0,) s8 ^ P8 a h0 |$ j+ z
.gpio = DA850_USER_LED2,
: \% d# b( y" {1 S .name = "user_led2",0 N/ S* s/ w$ v4 {/ ~# T* T
.default_trigger = "default-on",
3 r" g5 D5 t, O$ a },
1 n7 f9 z# |, y {+ X7 z9 {7 Z" p. @1 @
.active_low = 0,, @( C7 g+ \3 V! i' a2 G5 L8 |
.gpio = DA850_USER_LED3,. W+ S+ \5 w% T! t" x( C# h h" \
.name = "user_led3", ?6 [8 Y3 Q1 T$ l. F7 o* C. s0 s
.default_trigger = "default-on",: a! y8 O1 @. k6 S$ U4 u# }
},3 g, S R8 N; t$ W/ D: q" y
};3 B& D0 P8 c$ G/ J# y4 Q
3 H% Z# [8 s1 X5 fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- _5 a$ Y5 q- W ^( m .leds = da850_evm_tl_leds,
9 N& m* ]1 n% F7 j P) X4 x' Q( ~! M6 S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! L2 S( k5 A+ `' G};+ U/ l8 f/ C, U' K6 A3 ?& s3 T
3 G* ^1 e& O) P3 s8 a/ \! ]3 Qstatic void led_dev_release(struct device *dev)
* M1 T0 F$ P) W: o3 j0 L{- [) I( a7 |% f2 k3 f! n
};
% C' c7 J: a: `0 T1 F
( O( d) @$ D$ v+ ^8 Z9 Z7 wstatic struct platform_device da850_evm_tl_leds_device = {4 l" c( T- m( |9 i( b e
.name = "leds-gpio",
: w- x2 G( ]$ J$ C) U/ T0 \ .id = 1,1 X* r9 i* \0 B
.dev = {) E; {2 K$ Z: a$ z' Y: D, |5 e
.platform_data = &da850_evm_tl_leds_pdata,4 V$ D# N( ]1 S1 m
.release = led_dev_release,0 Q) Q7 u4 Z+ u2 ^5 x" Y; q; ?
}" T7 s0 r0 }+ @( U: [' }. j/ M2 q
};6 Q5 C1 D! H3 o: j
7 M+ z* q0 K: j3 z# L& k. l
static int __init led_platform_init(void)8 Z9 |6 H+ N. e
{
. H' f$ r( X0 X: U( \0 Y6 v int ret;( N. L: o% K% T8 S6 H
#if 0- r# T) s9 g5 N) N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# t2 s0 k3 R( H$ S% X+ y3 } if (ret)
& v8 q! n F6 _$ m0 S$ A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 T' H6 {( r3 m. k H "%d\n", ret);
8 `' Q, D5 U8 n a#endif
; |! {3 U# n3 l& o ret = platform_device_register(&da850_evm_tl_leds_device);2 c5 s) O, \3 R1 u8 f1 g* y
if (ret)
8 j8 T) S `: ^1 { pr_warning("Could not register som GPIO expander LEDS");8 P& } z1 \3 D+ r+ u. t9 A" R
else1 i' \: g; T4 x* ^2 K9 p
printk(KERN_INFO "LED register sucessful!\n");- {# h( I/ Y8 y
( b3 s& T5 w! l5 M" T- k return ret;
8 l/ X4 Z( B* u% v; e: H6 o}
j0 @ F9 Z) |7 @1 a1 Y: p, b# Z: Z6 g; f* t B3 h, [" n
static void __exit led_platform_exit(void)0 P' w$ P/ f4 H0 b& n
{
" H# t( ?$ F/ [# }5 w. i6 a* } platform_device_unregister(&da850_evm_tl_leds_device);! V; y8 {0 f9 N7 P6 t
+ X1 g+ O8 S i; \& j! R: h printk(KERN_INFO "LED unregister!\n");
5 n- @ o5 c% u2 Z5 E} K7 r5 o2 J( e
% \1 L/ I: E* d2 g3 P0 jmodule_init(led_platform_init);
& J6 ] i8 d1 Z) M$ pmodule_exit(led_platform_exit);
2 P; }: b* G s$ E+ m6 E ?
2 _! t) {2 P- j7 Y8 FMODULE_DESCRIPTION("Led platform driver");' P' l w+ D4 S$ z
MODULE_AUTHOR("Tronlong");
+ ]3 Y9 x4 M- m) [MODULE_LICENSE("GPL");& E( g4 L) S+ k
3 P8 n+ c7 Y8 i9 m# c/ w |
|