|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! |! F4 k8 n% z/ n7 r
#include <linux/init.h> j: ~& T% F* Q& s! }- a
#include <linux/module.h>
% {$ G* R' `' C3 s; T/ {+ P#include <linux/kernel.h>
) q- B9 q K" `( I2 s#include <linux/types.h>5 E( A: F; y% z9 L* }& K8 \/ y
#include <linux/gpio.h>
) m% K4 G* y+ ^/ _9 T6 M#include <linux/leds.h>/ l% @. G9 i I R6 L; Y
#include <linux/platform_device.h># }) F; e0 n2 F9 P2 X1 S9 c
f$ w, w1 d$ G# P) X; |, P+ i) J( d
#include <asm/mach-types.h>" c% p) d5 u/ w1 S) A. \ G3 ?( F
#include <asm/mach/arch.h>3 P1 C* G* V9 x1 b6 ^
#include <mach/da8xx.h>0 h) A/ g$ ?7 B* [" x8 P
#include <mach/mux.h>
9 h+ k7 i6 W* g5 S$ z6 R- Q4 T4 z8 @) s$ j8 A3 D: g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 g' s" J z6 S" x7 V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( p3 n* E5 ~5 ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- C0 s& X5 Q+ G2 i0 i" C t n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) |& w5 p T4 K( \
7 A/ V- i" u' I; s& P" }
/* assign the tl som board LED-GPIOs*// W# ^8 X L" l
static const short da850_evm_tl_user_led_pins[] = {' `0 f5 D9 n2 s4 N" Q4 D( v9 Q1 t
/* These pins are definition at <mach/mux.h> file */
6 L2 t, s! L/ V) |/ n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ M( v4 R2 x m+ t( }
-1- Z% D* P! b# l
};. h, t# Q9 T3 _
]; h/ A9 Q5 N: @
static struct gpio_led da850_evm_tl_leds[] = {2 q/ o. J+ j0 }5 v* X
{
% t$ s2 A. w! t2 E# I2 q. m .active_low = 0,
4 I6 r" b S1 \ .gpio = DA850_USER_LED0,
) {, U& I, s! d' d6 t; B6 d .name = "user_led0",
; ~: Y6 m; d8 I3 H; Z7 {: A1 @ .default_trigger = "default-on",8 t, |6 x& M* R% M
},. e8 i; I" {9 {' C+ a% N5 e
{
% i' ~7 j# w3 M .active_low = 0,1 y3 E* O7 m2 q3 `+ L
.gpio = DA850_USER_LED1,0 ?% N$ [% l7 E8 V- x; }; g- D
.name = "user_led1",( V: A9 W9 {: _2 s! X% O) Y
.default_trigger = "default-on",9 B* J4 O* i: d! X$ s7 ^1 A
},
- n$ k2 @/ N; t# f* H! i {# m4 N- S6 x& a: W2 q5 t
.active_low = 0,1 q4 T2 N" W/ Z3 Y5 I6 D
.gpio = DA850_USER_LED2,
' \5 {# w4 m% D4 r8 z$ J0 c .name = "user_led2",
5 f/ g9 e: v0 r0 ] .default_trigger = "default-on",
5 m; H0 X% `8 j2 X: \ },
4 W: v; ]* ~' z- S; f {
) a4 R; U9 V7 c3 Z .active_low = 0,
: D; O! ~! [* @5 Z$ w3 ?) u .gpio = DA850_USER_LED3,
( J0 c6 W9 }+ }* s3 Q, ~ .name = "user_led3",
' E' W# D$ u+ N7 f! `: k3 [6 f .default_trigger = "default-on",0 Q3 y& A4 P: i* _. D
},2 Y4 F2 S& j- z6 D3 n( W; s
};
$ B! [* f# P% h$ ^# r7 G- N
5 s5 B: q2 [3 jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# d+ i: i, `5 o
.leds = da850_evm_tl_leds,
& r5 E1 ^% }1 p8 d/ n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( \/ P0 P/ b4 F0 C
};
5 o4 h0 i* |5 J: M2 a- P3 v7 E! w2 G
static void led_dev_release(struct device *dev)
" M# s9 ]$ e+ H3 ?{& N7 Z7 `9 z! V0 J5 g
};6 C( t* G& S& T7 [
+ D4 x) Y0 ?+ o4 H+ O! Q
static struct platform_device da850_evm_tl_leds_device = {
# Y9 Q6 i# t% ?$ h* `0 l% u5 K6 @ .name = "leds-gpio",2 ?& ~5 K7 a3 Q! I7 x5 y- ?) J" a
.id = 1,
0 }' M% Y* x/ g5 _ .dev = {
) a, x! Z* M* E8 a0 W .platform_data = &da850_evm_tl_leds_pdata,- a8 i& l2 E" B4 B
.release = led_dev_release,' Z+ g) w( ~8 ?8 ^+ _# P
}
! N+ ~, U, C4 V4 y};
8 g/ o; ]: K( O% f5 M4 k
" ?1 D; B& D( c" A) r$ k/ ostatic int __init led_platform_init(void)
' k% q* n6 M7 _0 @{
8 _) j6 N9 V ?9 I; U3 Z4 m- I: S int ret;' E$ D0 y/ Q% b/ r6 H- Q) h
#if 0
3 F; |0 x, S9 u5 H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ s ^9 g, ?* D% [5 ^
if (ret) t$ Q' m8 _8 Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( f3 _( @! s \8 g "%d\n", ret);
9 S* b8 n0 ]: A- N" M1 `6 ~#endif
, X5 B2 A8 }+ P ret = platform_device_register(&da850_evm_tl_leds_device);8 g* Q- Y4 w+ v' u* j# `% @5 [
if (ret)6 C) z9 Z. v) L$ I2 ~& p7 F
pr_warning("Could not register som GPIO expander LEDS");: S' l/ R- E; L
else9 ?7 u4 [. C4 C4 s
printk(KERN_INFO "LED register sucessful!\n");. I" r2 u4 ~( u+ Y, G
- r6 F2 c; M. i& w return ret;6 d3 T1 k: _- Y8 \4 q
}
. B4 }2 {* K3 B1 X/ P5 o6 ~8 U' h2 I, |) ~( E0 r
static void __exit led_platform_exit(void)
( x$ E2 b1 \3 f/ z% s! R7 h{! W5 b4 u( d5 c
platform_device_unregister(&da850_evm_tl_leds_device);# {& J- p* N% J' r
, ~! J4 R( r* ^4 \5 G printk(KERN_INFO "LED unregister!\n");
7 L& v1 b. }' C; F9 @8 Y6 h}
! j" R1 z- }) m4 f. X! v. y0 z
h6 x& N7 v# ]1 n0 t; O* Nmodule_init(led_platform_init);9 h& E, X% k. x& v+ o2 c9 ?
module_exit(led_platform_exit);, k0 I4 a2 |& V
f3 q$ z3 t+ n3 v" k \
MODULE_DESCRIPTION("Led platform driver");
: Q# |$ N9 i& o* e8 }MODULE_AUTHOR("Tronlong");
) A; X" Q' g2 q4 \4 A) F9 jMODULE_LICENSE("GPL");% O D* A3 g$ U
9 y, N; d" b, w7 `, U
|
|