|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- {1 L1 @6 `" d$ f4 ]#include <linux/init.h>
j( A5 v# x& n+ p4 N0 S0 Q#include <linux/module.h>1 U+ X- w5 ~( q
#include <linux/kernel.h>. j$ b; _" s# P5 n9 L/ [) e
#include <linux/types.h>3 U3 ]: s8 r z6 ~% u
#include <linux/gpio.h>2 ?! f7 ~6 o, q @" @! b" A
#include <linux/leds.h>
1 y5 U: e7 I; j& L#include <linux/platform_device.h>( a: m4 E2 H- J
- b7 i) T# ^8 ~" W8 B! }
#include <asm/mach-types.h>% [/ m# V2 R K5 G
#include <asm/mach/arch.h>+ H* Q5 U3 Y5 e2 m0 N
#include <mach/da8xx.h>1 K/ i% Y' [; I9 S
#include <mach/mux.h>
0 S9 A: w% |: `4 [; j9 A3 @- I( K- T- F* \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 W5 ^! Q! t2 X3 y' G& i( M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* S5 n2 N# D+ c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& [/ {9 ?8 |: g# _/ s* [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ [/ [- v1 x- |' [+ ^
( q& w0 \0 m8 x, ?) w' }/* assign the tl som board LED-GPIOs*/
, j7 F# F( }7 Sstatic const short da850_evm_tl_user_led_pins[] = {
: Y' T2 T- z' Q3 P: `6 ^ /* These pins are definition at <mach/mux.h> file */; ]% j5 X; t- W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 z* U( }$ z' w8 y0 [ -1' @3 Y! k" D1 \, L' T
};
, H6 O4 I+ j6 ~% ~. C$ a& b6 y+ y: K+ a- H- p" ]+ U; H
static struct gpio_led da850_evm_tl_leds[] = {
, E* V/ J d) g# E {" K! }! x: H/ T2 P
.active_low = 0,
- w! ]8 }, ]2 I; ~$ n7 v1 @( { .gpio = DA850_USER_LED0,8 f* o$ _; A- Z3 W. E
.name = "user_led0",* f) `8 y% @5 a6 O0 e
.default_trigger = "default-on",8 d8 Q! l7 ^6 B* U/ S# F3 O
},/ g! R& H6 | x* m: ?1 Y2 [
{4 U4 j4 {) r( P
.active_low = 0,( I* |* T; V' Y& \% ~3 J0 P
.gpio = DA850_USER_LED1,
2 H3 j& u8 \! ] .name = "user_led1",
3 O9 M0 s1 D1 R# X( N .default_trigger = "default-on",
2 ]4 }' a4 i+ w* y },
5 @0 {1 y* h6 i% L& e$ e! a' J/ Z {
9 j4 }2 c7 e$ a3 F7 T .active_low = 0,
: p+ p* j, r. P7 g; ?: c' h .gpio = DA850_USER_LED2,
1 a" O& C0 u$ i .name = "user_led2",- _, M/ J0 a4 P; \# {! c
.default_trigger = "default-on",: G2 x8 J3 V0 ^; V
},
5 |+ i1 t/ h" ]4 A- v. m- a9 Q {
/ p/ U' @4 D" j% @ .active_low = 0,! u; k: `7 q1 C* ]" O5 H, s5 l: E' N2 o
.gpio = DA850_USER_LED3,- y8 i8 D- l, a! d K8 B5 T% ~" V
.name = "user_led3",3 ]0 U& {: i9 c; w# J
.default_trigger = "default-on",. C; V9 ?+ M% L) U
},
) {# D! n) A# W};
1 @! U0 K) }2 D7 u2 p
/ h5 ?% u+ m) I9 J7 G% u Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 e. }$ U) `* G! ]) T9 f+ e
.leds = da850_evm_tl_leds,# z7 N6 Y& d# \/ U x9 J# | s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' J4 L" u6 t. H) C# {0 M8 B) I. k' M y$ G};; I7 L0 Q0 T( A) j2 R% d
& |( a3 t5 Q$ _3 U
static void led_dev_release(struct device *dev)
8 _6 u% K9 `* O{5 k+ z% }. h) c
};
/ `$ _! q& ~$ y9 E
' t( K2 \& H+ {/ u& cstatic struct platform_device da850_evm_tl_leds_device = {
+ h7 k3 Y5 p' e& Q# K% s. s .name = "leds-gpio",5 t4 D: p; t0 C9 f3 E
.id = 1,2 _+ O, V! b) \ e
.dev = {( r6 A8 ?% O9 a$ S) H0 c6 k
.platform_data = &da850_evm_tl_leds_pdata,8 E0 T$ W* p& g/ [! L
.release = led_dev_release,7 k) V9 w. L) Z; i6 |1 t1 l. T! T
}5 w- C+ r' }/ E/ ?
};% N$ j/ t1 `, P
4 q* e: W; {' n/ }1 G( X4 D
static int __init led_platform_init(void)
! C2 s/ q# {$ G{
" d3 E5 ]2 x5 R6 t int ret;% y1 g9 f- S+ E+ b" f5 G
#if 00 ~5 `! l' q( s. M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 a: q, s0 b: O3 ]" i5 Q+ V0 D
if (ret)
7 U& Y! w5 ?. k1 [( o6 C4 u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 A6 `4 m. J4 Q2 B# g0 z8 f, @
"%d\n", ret);0 j7 J2 o' m; a5 c" W9 L
#endif
# s! T6 P3 E$ d2 ]0 h7 F ret = platform_device_register(&da850_evm_tl_leds_device);
( z/ z) e0 s! ^- t if (ret)
2 }* A2 C7 V# R* m& x pr_warning("Could not register som GPIO expander LEDS");$ f* S; j1 y, m5 `
else3 U O7 D9 l7 l; F
printk(KERN_INFO "LED register sucessful!\n");; F ]0 H/ Z. S/ v" w
+ U# g6 e& d- j! \$ `. \% a
return ret;# ]' Q l+ v; a4 u) ^
}5 l; \9 \# Y9 F9 @0 F+ l( `
9 I/ v/ K/ v9 M4 M% xstatic void __exit led_platform_exit(void)
; |; S ~4 ^1 Q' A0 [: Y( V{' n2 F- g) ^# [+ O" N& j. f' S
platform_device_unregister(&da850_evm_tl_leds_device);
* z2 _/ |/ T) f7 v0 \: B( k* ^3 o
5 Z7 O3 R2 |. o8 [5 Q! \2 S7 J printk(KERN_INFO "LED unregister!\n");
v% M( q" ~: A}
1 V% U G, X+ X5 \% I4 T
0 P% Z1 ~3 j$ ]1 |module_init(led_platform_init);
0 A+ p/ I/ k8 ], rmodule_exit(led_platform_exit);
! r6 t% f8 `) [4 w. t, p; ^/ f* \. x7 j+ Y
MODULE_DESCRIPTION("Led platform driver");$ _. z& ?8 ?! s( D; G
MODULE_AUTHOR("Tronlong");3 H5 U1 {9 h" Q ? T
MODULE_LICENSE("GPL");
( G7 |/ s, D; `5 u! C- G5 O$ g0 ^8 X: O
|
|