|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 {: x; f9 w5 A; ^$ R$ @. \, F
#include <linux/init.h>4 R9 T q6 }0 ]/ m" m
#include <linux/module.h>3 P, q! W; ~& B4 ]1 E* t4 B1 e1 c
#include <linux/kernel.h>' x5 y% ~% P, [: O
#include <linux/types.h>. `+ L% g$ O) m* M# W. D- I, z/ p
#include <linux/gpio.h>9 a1 W2 S# b. _8 o- d
#include <linux/leds.h>
) p5 e: {- x" b$ }" j- e: C#include <linux/platform_device.h>
& E" {4 X F9 h' F! V. a4 B6 P z' X: s
#include <asm/mach-types.h>2 b8 X! g8 T& V& Z
#include <asm/mach/arch.h>
% T3 S' m+ S! {: V#include <mach/da8xx.h>- B X) b& S8 v/ j) V1 Z
#include <mach/mux.h>3 z$ H, U- s" q# V
/ k6 F' w; Z- n/ A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 Q0 H6 x8 I* T( x* b5 b5 c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 ]( Z3 M" _% r( u' [- P: A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
R0 n% Q7 c* b#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* T" E: \9 B9 [( W2 j% n2 F0 I" v4 `
! _& k: T0 I g P/* assign the tl som board LED-GPIOs*/8 Z6 T x( ^' }: {5 p
static const short da850_evm_tl_user_led_pins[] = {
_5 \9 T( K9 a6 l( K A /* These pins are definition at <mach/mux.h> file */! I* W0 _% k: R2 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ M0 ]" p6 ?" _/ K2 v -1
: X/ D. n/ N% n. V G};
, S }, X' u9 u: P3 F" g
1 [. B) E2 g% o% v. ~7 [# mstatic struct gpio_led da850_evm_tl_leds[] = {
4 {8 O$ M0 k# |/ \: p! Q {
& p& Y* f, j- i( n .active_low = 0,6 U }8 n3 [, I' p
.gpio = DA850_USER_LED0,; y/ x9 G- H& N7 f
.name = "user_led0",
# S! H# m0 r2 ^$ N .default_trigger = "default-on",+ Y5 {+ N \5 s8 X( v
},
4 @7 \; I! x0 b w& y4 D( P+ { {" }$ p+ g( N2 t4 L0 X+ \! i" l
.active_low = 0,8 o; ^2 A& O d$ o% i; x
.gpio = DA850_USER_LED1,
' E+ J! P& y% E3 d* x+ V# @" M3 w7 n .name = "user_led1",
3 u4 _! N" _) P0 G* T$ ~ .default_trigger = "default-on",
! x8 B3 \% |$ \2 J% [2 X# M },
7 s: T4 X, p4 b2 f$ h {
* J0 P; | b$ z- ^' V9 Z; T Y .active_low = 0,9 E7 B, b, e' E( x7 ]
.gpio = DA850_USER_LED2,
1 Q/ H! m1 p) Y- `( X .name = "user_led2",
4 l4 x$ e9 O/ i/ e& @ .default_trigger = "default-on",
" s6 j" U, E# C! [: d4 z },8 T5 c* P7 I: U& }7 D) t0 l
{: Q/ K( p$ V/ f ]+ o+ J
.active_low = 0,
3 p0 T# a- t& v% g .gpio = DA850_USER_LED3,. ?( C/ n( Z. P- Z6 c J% M
.name = "user_led3",; Q" G' Z& ~3 Z/ l4 v
.default_trigger = "default-on",
9 w7 m1 R% k/ t: m },, D& V+ t/ S8 Z
};- R2 ]0 H7 Q1 ]$ |) N9 z
, L7 s& ]% N5 C- z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 x) i" ^8 W9 l0 n8 s: z+ @: [0 H .leds = da850_evm_tl_leds,5 O* S7 o: L) L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% k' O" B$ G. v7 i/ Y0 ~. C; s
};2 g$ x) d' U# _; z0 K. K
* G$ J! D/ p3 ], s6 g- Q/ {static void led_dev_release(struct device *dev)
) M+ {- d/ h3 W2 W+ q/ ^0 C7 }{4 X7 _; q6 @( {* X- j
};" y$ ?5 X' E0 {2 Q+ t3 d; l _
! g0 Z1 }; [9 S8 _, ]9 ]) P' ~static struct platform_device da850_evm_tl_leds_device = {
$ Y1 J% k- z4 M$ P7 t9 ? .name = "leds-gpio",2 @/ M& g1 r& f, K
.id = 1,. y) ]5 q% R. S% c$ y" b, Z
.dev = {
; K9 D4 G. j) j5 W6 o) g5 a- n .platform_data = &da850_evm_tl_leds_pdata,
0 a6 R+ Z) Z: b8 C1 t. g4 I .release = led_dev_release,
- A2 N. ^9 L) z$ E+ L8 v$ Z, ?) V8 P }6 E% s. o! Q: h R
};
9 r$ o' B3 g8 h# a$ c4 {
. {/ ?$ Z! U# z& m7 J# |' U4 |static int __init led_platform_init(void)9 V6 g1 X5 E7 [& a
{
2 `4 p' T# @8 W) M4 M; r int ret;% E% y, N: g6 q2 V
#if 0
, \- M0 a- W7 k6 Q4 Q& r/ M% i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. m1 k, S" k% d7 p) j- p
if (ret)3 p" x! X, T+ O4 H5 U- Y% l$ p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! `! d4 i" P2 V5 _ "%d\n", ret);
. q4 u/ b) S1 J# C5 L- b" r l#endif2 G9 r- X9 x1 v$ d* |; I# V
ret = platform_device_register(&da850_evm_tl_leds_device);
) z/ ^4 V% A3 W! b" O) X- A if (ret)
/ B+ w$ h( ?" C% M pr_warning("Could not register som GPIO expander LEDS");
) s" W+ h( p' ?; U% P- @0 h else
& z5 ^9 I3 F/ M! I2 F* D printk(KERN_INFO "LED register sucessful!\n");
! E+ ^: j# M4 |# k: ]3 W" Z& g' _0 T: U% V& {
return ret;1 A5 H$ G0 {6 [* o& a8 f6 \
}0 @7 D6 J: H1 ^/ C4 O3 U' C3 j" h
) L/ j# \7 X: h
static void __exit led_platform_exit(void)
& ?2 ]4 e! G1 ~8 E* ?{
+ @7 D- I. _% |) D+ Z5 _4 m platform_device_unregister(&da850_evm_tl_leds_device); _ D& w* s5 ^- r% r. w9 G# T
7 l8 _* ^# T5 z3 `! _2 R printk(KERN_INFO "LED unregister!\n");
9 Y. ~/ i( e/ ~9 n}
; s5 E* S) t8 f3 ]. F
* P' Z6 [1 ?3 ~$ ^. y* |module_init(led_platform_init);
$ ^4 S0 r" E" l' F6 b5 Cmodule_exit(led_platform_exit);0 E% O) R# \0 }8 _1 Q
: [9 c5 b j$ K; p$ A
MODULE_DESCRIPTION("Led platform driver");# H+ \/ F' m$ a
MODULE_AUTHOR("Tronlong");: s4 S; I* q. @
MODULE_LICENSE("GPL");
- B- B6 |2 J# ^) v* w2 k
7 v# b! K9 e& V4 e3 x& S! G0 w |
|