|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 A/ @2 `8 Y# ^& t9 w' y
#include <linux/init.h>
+ q2 S; n* g" w9 e6 o |: v7 G#include <linux/module.h>8 J( z7 c; X* L' q- j) h+ Y7 p
#include <linux/kernel.h>4 o* ~% r; M4 L* i% b0 w* c0 r0 o
#include <linux/types.h>
( y+ u0 g7 M4 l#include <linux/gpio.h>' A; Q1 ^5 A3 ^4 m
#include <linux/leds.h>' P. L/ j4 q \
#include <linux/platform_device.h>
" A# G- U+ X* I
% b& ? z; B) E. |0 A# B, w$ Y#include <asm/mach-types.h>
" n/ @* T7 s& D0 t2 {/ N- h. Y+ y& ?#include <asm/mach/arch.h>
. U5 V5 h6 f+ i/ ^8 D( P#include <mach/da8xx.h>1 B( p2 ]5 e5 U3 k; y
#include <mach/mux.h>3 h) p& {. l, V1 ^9 }( E
0 d+ P- A u' f' g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 d: n( Q- F" [( j% M+ z `3 `9 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ J- Y5 ^2 j+ Y+ @/ M& j$ L
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 c3 {" D- Q. @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# y' U2 W/ }7 m, x9 G
' G3 k' }; c z. t# e, ^% h; r/* assign the tl som board LED-GPIOs*/7 g2 F: t6 Y4 R; Z3 _1 m
static const short da850_evm_tl_user_led_pins[] = {
+ p2 j( ~' j5 s; n- y& W; G( I4 j7 M7 T /* These pins are definition at <mach/mux.h> file */3 \7 i% t2 ^* p/ B& f8 V: k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- f7 u, V/ t7 G
-1) @3 @% j) W5 I. p
};
- B) j1 O' u+ p7 @1 o
2 [8 Q( ]' E! r/ m A$ l# xstatic struct gpio_led da850_evm_tl_leds[] = {
& u4 ?9 s9 C* }7 i; j" { {: n* n1 w+ c8 ~* ~* ^7 T7 Y* a( a
.active_low = 0,
" P1 |/ l- Y0 Q# Y5 `; a- W% C3 A .gpio = DA850_USER_LED0,' R" [* Q+ R P% l1 T1 v, S3 ^" A
.name = "user_led0",
" R7 {# c: H4 l, v; e! J- A .default_trigger = "default-on",+ M: {' A- g8 I9 b8 a" l4 p
},
0 T& j5 p7 _% y& O6 \. s {
0 S. `5 H6 H3 l. c5 k$ r1 h .active_low = 0,
& H5 `; X& w/ @$ t .gpio = DA850_USER_LED1,% S: ~1 p2 e" m# `
.name = "user_led1", g& B% `+ T9 o; Y% H3 G, C2 |
.default_trigger = "default-on",) p: o% M! u. z
},- g9 X8 L; F1 H
{( B/ e% L8 G4 j+ p3 q
.active_low = 0,( m# [7 l4 C# \: b- X
.gpio = DA850_USER_LED2,0 r' M# M2 G) C7 Y2 |/ O9 K% q
.name = "user_led2",& M, c* s# O! v6 z9 y
.default_trigger = "default-on",
% J* o* k% E0 S% J },1 a/ F5 Q. Q2 i
{
* V# ]2 C, {4 f' a, O4 S .active_low = 0, P7 Z7 v6 ]- o U6 C" v% q! d
.gpio = DA850_USER_LED3,
/ W8 k" q6 X4 ?: K* q9 C* X .name = "user_led3",
& b& |' P' Y3 B4 |) ~ .default_trigger = "default-on",
- H7 @8 G9 K8 u }, @% M( c$ O& L4 A5 D! u
};
5 n! K" n8 g6 ^% R" j8 R+ ~0 a+ R* {7 h: \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 Z) D0 F, w" \ .leds = da850_evm_tl_leds,
2 a/ R& k; o0 E! f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! W+ c4 B" a6 s* o0 y+ t/ K# F
};
, x. F* P7 f1 L/ w
4 U' ^5 S$ A9 i; H1 i7 N% Zstatic void led_dev_release(struct device *dev)1 v& b. M" l# I$ X
{
# P) K) z5 o; P U7 t% i9 \}; ^' {/ M' Q4 K" y
# C: H7 V1 x& N
static struct platform_device da850_evm_tl_leds_device = {
% v% W3 e+ n& W, `/ d .name = "leds-gpio",3 s: _/ ?9 n- a! I# o( m' l) \
.id = 1, i( \- ~1 d! I9 q9 U5 M+ P
.dev = {8 R" U+ z- a* D, c- H
.platform_data = &da850_evm_tl_leds_pdata,
2 t0 y! A/ q" I! [ .release = led_dev_release,
) ~6 [, }4 T% j( ^ }0 M7 n( Y2 h. ^ _3 {
};
- r4 U+ t/ w; k0 @+ g4 F. V% }. W Z8 j" a! s" B, v% a# X4 p
static int __init led_platform_init(void)
3 _- i* ]7 ?7 W{8 Z6 g. z. F$ ?* R1 S) Z
int ret;) `2 o* L# R% A) E
#if 0. Y6 \4 f! N# o' S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( n( }: b! v9 l, R/ M" y! M
if (ret)
/ a$ ^1 y- W" p e! s$ c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ V* v" E- K8 ?+ O
"%d\n", ret);: d7 \# M6 ^$ T b3 J
#endif
- D, w+ L$ M$ u% m# C. X( V ret = platform_device_register(&da850_evm_tl_leds_device);
4 D& n7 _/ r* `' T if (ret)8 n: ?0 u5 Q8 ?/ T# D1 b, L9 f2 s$ P
pr_warning("Could not register som GPIO expander LEDS"); l9 i* h% F, H& C
else
+ v& E; w- N, U! @: u printk(KERN_INFO "LED register sucessful!\n");
, w0 w& W* z$ o2 j: j% a, p' R- W4 D) K; D% E0 _( X- Z8 v
return ret;
* V: B1 |% J1 B& @" |- R- m" z}4 Y5 Y# [+ F( v9 e; C7 s8 k
. m9 l' j' @3 n5 U: P! C5 I' Ystatic void __exit led_platform_exit(void)/ W* } |/ P) B$ W
{% G' {1 D% z8 l" {
platform_device_unregister(&da850_evm_tl_leds_device);
Y' Q. f) ]; M: m1 t+ Q
% |& R' a! u( M, m) a9 g0 c& D printk(KERN_INFO "LED unregister!\n");) K2 a( j" i7 K+ Z9 j! t+ |* e
}2 ~5 r' s# d, m. \! l2 U1 T7 Y' C% H
" G, r+ s. {: v# Y. _6 [
module_init(led_platform_init);
) n0 n0 t: t+ dmodule_exit(led_platform_exit);
0 @ r0 ]/ f$ `& E: `2 j2 E! Q6 [* E2 F3 g: Y3 F# `& d7 V3 o
MODULE_DESCRIPTION("Led platform driver");
) N% E# Z! O/ A7 A6 M( z, H# t: BMODULE_AUTHOR("Tronlong");0 e4 X+ m. h8 A" R% K! b" J
MODULE_LICENSE("GPL");
7 _- b$ S2 [3 h( A6 H! ]
' a" h; Y ? w! {# n |
|