|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% x/ ^) w8 \: j# v. g0 i
#include <linux/init.h>2 K& s4 V5 f# P/ M& k g
#include <linux/module.h>2 q& f+ }0 m" l% b1 u. @
#include <linux/kernel.h>
V6 L; R6 R- q- M' u#include <linux/types.h>
$ ]) c, z5 |* l#include <linux/gpio.h>- K3 l% X @, u3 F0 M
#include <linux/leds.h>
, O/ [ ?- Z3 T8 _#include <linux/platform_device.h>
( l4 ]1 k( o% ?1 ?" o4 G
: D( Z' a, J- y3 m, `. W#include <asm/mach-types.h>
0 ~" p9 c7 G" ?6 z- g1 }* z#include <asm/mach/arch.h>
$ K* I9 w! g T8 m0 R: S#include <mach/da8xx.h># @2 f" a3 v( m! K# M3 N0 w
#include <mach/mux.h>
4 W7 q) A5 s" V9 r6 g, F
: F! j% B, Y) F( `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 d$ G w- l0 h7 h, |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 A) x' |. O0 [, ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): t% `8 _& E% d8 M2 s" E/ x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* [% H7 k7 M0 {8 }8 _( I
9 c, H G6 j( ?. D+ ]7 a/* assign the tl som board LED-GPIOs*/
9 G+ L8 I9 r( D6 ?static const short da850_evm_tl_user_led_pins[] = {
( `' T+ V% |0 B% ] /* These pins are definition at <mach/mux.h> file */
: b% g- p/ x1 H. W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, f2 @( i! t( C' v -1
, c! r$ q' }3 c6 |};& b" T: _# p, D' V# @ M/ Q: h4 g
$ V% B3 F) i8 R" ^ Y
static struct gpio_led da850_evm_tl_leds[] = {9 w, a# f! o. k! X# {: d3 M' u9 k0 O- k
{: d @6 N9 Z* V/ Z- _) \
.active_low = 0,
: w% q. I9 D( \3 y1 O .gpio = DA850_USER_LED0,
8 D2 e7 x* q# k: Y! j .name = "user_led0",0 i8 c1 L* W& O' ^, Q
.default_trigger = "default-on",5 ]9 w' C3 J) i& G, [* _7 _& K- ]- z! d
},' K, M" Z& V, I: r8 U t S- Z6 J
{
7 c0 }, t- A8 P' @ .active_low = 0,
/ m) J* T7 V9 N2 M! J; M .gpio = DA850_USER_LED1,
6 P3 ?, Z& w; [- _- M .name = "user_led1",! U. m- E `$ c+ u, e
.default_trigger = "default-on",) {( e. V6 C" e. u& f) h1 o
},' `9 H! _2 I4 `! C
{
: }% A1 \$ i \( O .active_low = 0,
9 f. y+ {0 F" k8 H .gpio = DA850_USER_LED2,) Y% p* @, W2 i3 T/ x' T
.name = "user_led2",
* Y! f& \: ` x3 z( [5 e5 D .default_trigger = "default-on",( X* f/ o! q% q% M
},1 `4 a# E; U d' r; ^. l7 z
{
' i/ Q: X* Z$ l+ n: k5 w .active_low = 0, S# P# T; d2 Z- \! K( j
.gpio = DA850_USER_LED3,
/ {. _4 ?6 I' A1 s; M .name = "user_led3",- v+ l3 ~7 ]& J' C3 x
.default_trigger = "default-on",6 A+ j/ n0 n: T( X! _ X
},
0 r5 {- R- `& w% j. G};6 R+ \( `( L$ u% ]' Z7 s+ p {
. g- D- \- @2 _" Q0 j- fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ g, ~7 E2 |0 O; Z8 a4 E1 a9 ?
.leds = da850_evm_tl_leds,
2 x. j. c: k5 c3 Q. T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; z8 _6 _2 ] s7 E! Z4 z
};
" p _+ L) N- x. @& J0 ]; G6 _" h. s
static void led_dev_release(struct device *dev)% c& m7 A; |& R& Q0 v* U
{* ~* c% x0 T a. G$ e
};
/ j! J) O1 |8 T% f* T6 M8 ~5 r! ?2 f: ~9 E9 d" \+ d: S6 Z9 t
static struct platform_device da850_evm_tl_leds_device = {. Z; Q8 a- b: ^4 j j! `! I
.name = "leds-gpio",( H/ U2 N3 n' m/ A) ?
.id = 1,3 E$ X. }' i7 @ {/ S0 {
.dev = {- b" M0 G( z1 O0 V3 I
.platform_data = &da850_evm_tl_leds_pdata,
/ i4 X# e6 a7 a .release = led_dev_release,5 v4 d, X, W! l: o
}
: f. z" O0 }+ S. x1 r% p, K \};
7 v' A1 \& s" E4 k+ v6 d2 E5 {! e% U6 Y' v3 t% y9 {& }
static int __init led_platform_init(void)
. C2 {4 n8 {' v+ J{
1 \+ a' s( {* f3 L6 A }5 J0 B* Z int ret;
) O$ j$ j4 b* T0 u3 r! e0 F#if 0
; K1 {, A# ]7 S1 V. N3 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, U W8 Y8 b* {, `' I
if (ret)
8 m) m: F! l: v+ z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! J3 Z/ U9 c4 n "%d\n", ret);
) N+ M/ d" |% u1 p- R#endif
' E1 R# X* B9 Y. L ret = platform_device_register(&da850_evm_tl_leds_device);
0 ~4 F* h3 t7 J. a. y. n4 X! m4 _ if (ret)2 g/ q; `( U! z
pr_warning("Could not register som GPIO expander LEDS");
5 t2 m% H$ e0 s+ \ else
6 D2 d# r @* _6 @0 T, r2 u printk(KERN_INFO "LED register sucessful!\n");
$ Z: `1 N% F0 F/ f2 o9 S; J0 q0 {3 l: @; W* X& Z2 x' T5 y7 e1 K
return ret;
+ R' b7 h ?6 r9 \6 b _}" N$ q- k8 p; k" J5 s; F
0 }# V9 t+ o( H0 f
static void __exit led_platform_exit(void)
' v$ i& ?- Q9 T" F7 i# h( A{
G! [ h! x( ?+ G5 R platform_device_unregister(&da850_evm_tl_leds_device); P% t. k- J! u, o% L( N
# I3 R) d1 l, U2 Q/ D4 | printk(KERN_INFO "LED unregister!\n");
; x* M# I: m8 J}
1 S8 @6 }- ~) ~+ m k J+ c! J1 `8 \$ k$ o3 P" P
module_init(led_platform_init);. c8 U' K" z2 T; m+ e
module_exit(led_platform_exit);! _" _& f* j3 N- K
/ D* b+ e' v8 i2 d0 tMODULE_DESCRIPTION("Led platform driver");
' m; I& o* |& i6 yMODULE_AUTHOR("Tronlong");; N' ]4 M: g# I+ a6 R; \, C. h
MODULE_LICENSE("GPL");
% g& h/ L! ]" o! d1 ~ c# A2 u4 Y# @* @# M! |) T1 _& }
|
|