|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 _# e7 F: i7 c* G& Y#include <linux/init.h>, @4 N% @) X8 R& i8 z# S' k6 M
#include <linux/module.h># G" i) q' l* m0 ~# J) a
#include <linux/kernel.h>
8 P4 e+ y2 G) J& Q7 m9 m#include <linux/types.h>; c% b5 a6 t3 W. r
#include <linux/gpio.h>
( G4 J- n; v7 j4 X! l#include <linux/leds.h>! U4 J2 w$ j% R! ?4 O7 h
#include <linux/platform_device.h>
: ?( V; n0 o- {0 D$ D' w2 L/ l5 d& ?6 j. K6 s4 ~1 ]% z5 o$ O a$ i
#include <asm/mach-types.h>
. |0 u9 j+ b$ [ A' X/ i% G7 ?; B#include <asm/mach/arch.h>
' Z/ p8 Y8 H$ F$ l1 W#include <mach/da8xx.h>
, B4 _% z; m$ Z3 B0 m# d$ D8 z#include <mach/mux.h>% g* D' f/ x2 j5 i1 a
8 W M) {0 Y8 L+ [) g. @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); U6 f3 `- ]4 J& J8 A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: g" o% Z3 \1 c4 N! F1 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 T: p' _! V. x3 K# d @8 ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ b6 u8 w% S- [# V" e/ o- e
0 J+ t: p4 _% _3 {% a9 ?- S/* assign the tl som board LED-GPIOs*/1 v$ ~4 y8 ~' ~4 H
static const short da850_evm_tl_user_led_pins[] = {
1 R6 L3 H. b& B1 |4 r, A7 y6 n, Q /* These pins are definition at <mach/mux.h> file */
9 o; a$ P+ c- x/ C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( E: i" V8 G( }" ^% l( L- I" L4 i
-1
6 @' a8 f9 c# C2 S: z' X};, J r! y+ ~2 `3 X5 n$ w* R* f4 Q* ?
5 Y% y7 ?7 H6 [: Q. u' a$ {" R/ |1 _
static struct gpio_led da850_evm_tl_leds[] = {
( k5 J9 y/ A1 r {
% y& Z, D9 l" W( ?4 Q" m; M .active_low = 0,
& J0 r6 t' Z7 h9 o4 x# S- q4 K .gpio = DA850_USER_LED0,; u: h! x- y" D5 e! ?
.name = "user_led0",
1 ?0 o7 J3 P3 d2 g) ?9 d* d' p .default_trigger = "default-on",
) L: x$ R9 T1 j7 u' e- H h },
+ t5 [6 b$ z- E. T {
4 `4 x$ l+ _) U, ^6 i .active_low = 0,( b9 ~5 g+ D/ Y6 x1 V6 t' ~
.gpio = DA850_USER_LED1,5 F# l* Z& p* B" r. t8 N. i
.name = "user_led1",. E1 M* \2 v# W. J' Q( n/ u
.default_trigger = "default-on",4 N6 T0 f9 |6 z# p# r
},
4 _( `0 @. A, k" [( E; q {
* l$ q7 @7 N3 f: C& l .active_low = 0,
) I; ^8 F4 n2 P! X. h% J .gpio = DA850_USER_LED2, f# O0 c/ A3 i* _2 L! y, C7 v
.name = "user_led2",
6 k- T4 l4 j0 e( D% A- X" w% B .default_trigger = "default-on",$ e; Q3 j; V& B x/ Y
},
" O: f2 t4 p, l( S {
( A( D3 t* I; [# E .active_low = 0,% E' I: B! N3 H+ z. E% k2 `* a' r
.gpio = DA850_USER_LED3,/ _% P6 L6 R3 F/ {9 Y
.name = "user_led3",. i4 J5 x2 h9 b& p; D+ c9 X
.default_trigger = "default-on",9 |, B) a3 V3 z, Q, P( t- ~& _! |
},1 a. G. z/ l% c, \$ M4 L
};+ N; r# O+ v- [* g
2 C3 X' H. C8 U2 T: N4 nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* L$ n/ N% w2 _( c
.leds = da850_evm_tl_leds,# ?9 V6 M/ u7 t5 B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) j3 k0 f: Y2 p* G* O2 R};( \4 h4 v, ?# F8 j
# f# Z/ _* V- I2 f- Z, N
static void led_dev_release(struct device *dev)( W% D( @( c: `% E( l
{
& x! x& w* E; Z" O5 |};- h4 y* B) ~6 D/ M% \$ ^1 ]$ {
- G+ D9 @" Z5 W, Dstatic struct platform_device da850_evm_tl_leds_device = {
; T, S" K) b4 e .name = "leds-gpio",
5 N4 v1 n3 ^: x# ?6 v+ X .id = 1,9 @4 M2 p2 X" d- j8 b! {2 [
.dev = {) o8 X5 h8 M+ ^* Y+ W9 m
.platform_data = &da850_evm_tl_leds_pdata,+ Z( i& ]; @9 u ~: f
.release = led_dev_release,+ N+ p: M N; N: p
}# u6 I; t: Z4 H8 w, S; W+ l
};: z$ A& Y3 @* U3 ]
1 U9 Z) Z2 V1 sstatic int __init led_platform_init(void)
( c0 d G1 A$ k% {! a9 f{
8 R& D) q Y, j int ret;
: @7 W0 l$ h4 W& o" o#if 04 s4 a3 H+ J4 o/ M6 ?4 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 k+ T. m5 G* t: M2 O
if (ret)9 A! p7 ^- R$ e. W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 @$ ~2 w2 K4 k! {0 V+ Z "%d\n", ret);* ?9 T# e8 k! `6 O' f% B/ K
#endif
$ x, P, F8 b9 D ret = platform_device_register(&da850_evm_tl_leds_device);
& E3 _9 ?- T9 _& o: v9 G if (ret)9 N. n/ ~# q% D0 r
pr_warning("Could not register som GPIO expander LEDS");! `, z& P. P9 M
else
: l% n! f E4 g y2 V" w' f L8 ` printk(KERN_INFO "LED register sucessful!\n");
4 I9 v5 p, n% y4 c, [
! L& o. |- t: ~ d6 \* X! O* c( U return ret;
& S+ n) y- M* t}
4 D0 L& s( j" \/ O* l* j) G- l, a z3 G; u4 W( Z1 ?& ~
static void __exit led_platform_exit(void)
& \5 }# \3 p" `; \3 X" J7 `* h{4 O$ Q! B6 J! e" b _9 _$ ]
platform_device_unregister(&da850_evm_tl_leds_device);7 s: h- x, b( \( c9 Q! P
) v" u( l, |1 t3 t! j( B/ R
printk(KERN_INFO "LED unregister!\n");. ? _4 }7 }$ o+ r, H1 l. m
}/ p: K* [& I: M
7 X* ?% z5 h& W; l5 _: Jmodule_init(led_platform_init);2 N P2 P2 `2 Z, n5 Y3 w; Q& A8 b- n
module_exit(led_platform_exit);
" y9 {. }& R% u" y8 U, Q: t; u2 |& B( m2 p7 l
MODULE_DESCRIPTION("Led platform driver");
- F B, G' d y+ N: |9 w% hMODULE_AUTHOR("Tronlong");
" i, O# l( N8 E* n. O% bMODULE_LICENSE("GPL");
* ]! A6 L- n3 c" w4 h0 c6 K3 X) P4 j0 S
|
|