|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* n5 s# M0 n- m7 e8 Q) }#include <linux/init.h>) o i1 b! p4 C8 e. y5 @
#include <linux/module.h>
& C" B2 A! {3 Z g w#include <linux/kernel.h>
, z: V+ U/ D! |- K4 Q#include <linux/types.h>: C& V! m4 ]& w2 Y. a
#include <linux/gpio.h>2 y% m. Q1 I, l; h9 j+ \& o
#include <linux/leds.h>/ h2 P; X6 ~6 ?0 P1 V1 ~; `' n: i5 n
#include <linux/platform_device.h>
0 e0 W0 [* I* v! I' w4 x# N1 a4 v! a3 \9 z3 E2 ^& h% j
#include <asm/mach-types.h># Q1 H9 K p& y B
#include <asm/mach/arch.h>% w$ y, ^6 ?0 j2 _. R
#include <mach/da8xx.h>
5 y% K* c j. r6 E" t" U& @#include <mach/mux.h>
/ t+ T; M" ]: H- f5 z
& A# a1 h! d2 A8 \: T5 K7 b8 e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 _2 f9 x+ P9 u# T1 o* v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( Y& m3 o2 f* B- \0 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 j3 F; H3 u2 N4 Y" u i* |+ ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! [" V4 s1 p7 i
4 f4 \7 O6 @- c" R/* assign the tl som board LED-GPIOs*/7 S/ M# M8 B4 p! Z
static const short da850_evm_tl_user_led_pins[] = {' A* {* J6 N4 r4 n* H
/* These pins are definition at <mach/mux.h> file */
' R, ]5 Q6 E# d, J3 o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 x" y# b* \3 ?) Z -1
- w a/ y. |' D f};
$ T7 x1 S- ]9 ?2 G1 _) L
1 g: n) w) Q+ t" [static struct gpio_led da850_evm_tl_leds[] = {
: t* x/ s; s o$ v, g5 G5 c {
% g7 d7 t# S! A .active_low = 0,& ?# ~1 \, l0 n7 S
.gpio = DA850_USER_LED0,
1 L9 h4 P; X: M$ Z6 U8 t# h& S .name = "user_led0",
( ~5 y3 o0 E2 |2 k0 U+ j) m6 t .default_trigger = "default-on",/ k. V3 n0 r% M3 {3 g+ y
},7 h7 V1 V- u2 k: H* ~
{
. Q& \, v# e( i6 i. F+ s .active_low = 0,/ h' J2 j a9 b: P
.gpio = DA850_USER_LED1,) ~6 z7 L h6 Z* w" R4 ~5 @: \
.name = "user_led1",
6 J% Z% u2 g1 U& l V .default_trigger = "default-on",
% X9 l8 ?9 k% r% w, K" N; s. | },9 s, m+ h: O' J! c( D J
{
' l1 x! z& I% r% k( k& n .active_low = 0,
6 w3 {! v9 H2 X* k- b .gpio = DA850_USER_LED2,0 a( Z7 t( W7 O- ^, D
.name = "user_led2",
7 S. Y1 G7 R0 ^ .default_trigger = "default-on",
p8 c9 O7 G; s/ | },- F/ ]2 x2 h& r7 T
{7 C% _& ~, {% t' r
.active_low = 0,
0 d2 S( V# z% M/ K; A/ Q .gpio = DA850_USER_LED3,* g) n* W$ t+ m, ?) E
.name = "user_led3",! O9 z; w0 ~0 W4 v" a' s' q' x H
.default_trigger = "default-on",
6 T4 Y8 N( P4 J },. P3 z: E7 D4 F9 s# ]
};1 b2 _$ w9 B' k/ k: ^
# j% u: j1 I+ C. A; j# ]$ a
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& @: Y4 f( \, ^4 P: \: j
.leds = da850_evm_tl_leds,$ m* l& j6 c5 a* q3 Q3 B- }! g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* R8 [8 ?' J/ E4 o* v& t! |
};
N. i! m4 u! m; K- L6 Q2 N7 o% m9 F8 B
static void led_dev_release(struct device *dev)
% Z) n# u" e. D/ Y" m{5 H o" F: w6 q- w
};
! Z* m8 X n. L( J9 l7 |' O h
" n$ @7 {/ ?4 X8 ^7 Ostatic struct platform_device da850_evm_tl_leds_device = {! m: M$ M, f, x0 @. _6 r; d% K1 o
.name = "leds-gpio",
& T$ _+ k+ b' C1 z9 f9 q7 _ .id = 1,
6 X- \3 H! ]) t7 J1 o .dev = {8 X8 g3 Z6 U+ w+ `7 n8 G
.platform_data = &da850_evm_tl_leds_pdata,
~/ Y1 D7 _4 k .release = led_dev_release,0 e0 P% j2 V4 t7 i1 B4 I
}
/ Y7 |0 j/ U! N, F};: ]2 B! z0 T; x. E( y2 D/ J$ _
1 w4 K5 ^0 f* n8 r6 ~$ N* U0 jstatic int __init led_platform_init(void)) }& S$ N7 n9 C9 N; @ ~
{
9 o. { E8 S% I! H8 B2 ^: x) x int ret;
7 L5 X- j" U' }8 y3 I) r#if 01 D3 ^% Q' n& x# e1 a, }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ e' l. ^. e! k) t' P if (ret)
4 g( r3 N$ E+ a! }% i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, M# R! }. ^. E# g! L. X5 f) t( Q "%d\n", ret);
. l& {! M" ~- `#endif
6 D4 i' O4 |+ t" |1 D6 R$ ] \ ret = platform_device_register(&da850_evm_tl_leds_device);8 n& u, h& ]: \4 N* U5 A( Y7 b
if (ret)) m B4 @- s$ b4 _/ \/ E
pr_warning("Could not register som GPIO expander LEDS");
% K7 V% z1 ^5 n4 _7 Y/ S9 } else, ^& `+ }! w0 z/ V
printk(KERN_INFO "LED register sucessful!\n");- w, i; v" i X, V1 o
~% k4 r0 J( L; Y% P% ~ return ret;; {% P% J( K; X, Q% q
}
8 Z! o7 I$ F% Y: B; n0 `1 k$ r% e1 A# u
static void __exit led_platform_exit(void)
, _6 s3 K0 C1 [8 Y6 c: E8 t5 Y{. k9 J1 |4 {0 q7 M9 |
platform_device_unregister(&da850_evm_tl_leds_device);
6 Q" j1 Q8 S0 u' j
Z" n: p8 A# ]) O# {+ A printk(KERN_INFO "LED unregister!\n");
7 @ ?- r. m' z}
6 F9 o2 i6 j" {# T( k, H5 p; B0 F5 i5 T. P8 E8 w1 ~
module_init(led_platform_init);
8 y# U; B0 s2 k( m7 ?0 Y2 P" Smodule_exit(led_platform_exit);
2 [9 g) N% S5 Q/ v# @. j! t8 e5 ^7 k+ R, R
MODULE_DESCRIPTION("Led platform driver");
! K' ~7 {1 n+ DMODULE_AUTHOR("Tronlong");5 o% [7 [; x7 P- m/ `0 L) Q& ^
MODULE_LICENSE("GPL");
4 r# k1 D% z i. R6 |1 G
8 e# n+ s, r9 ?( V |
|