|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& Z, q8 i1 b1 q+ V' }0 w# |#include <linux/init.h>+ c( y" w' `, w X; u
#include <linux/module.h>
* R8 h% x* M& G5 ^# X#include <linux/kernel.h>3 }) n8 j2 Q. n; y& Z2 D
#include <linux/types.h>7 w$ ^: \; Z$ L& q) m
#include <linux/gpio.h>
/ g& n3 o9 |. s$ Z8 L#include <linux/leds.h>
3 y! r$ L" l2 C8 F, Q#include <linux/platform_device.h>9 T" o) @4 ?. }" g) E: n
7 R0 U3 g/ B7 U$ S/ b! H- \
#include <asm/mach-types.h>. P9 i% v l; S: g! z7 M4 g
#include <asm/mach/arch.h>; s4 R8 u; Q# O6 {. H# F- Z
#include <mach/da8xx.h>$ d' `# O1 a- q: o" w0 z4 k
#include <mach/mux.h>
! j# U! _' O7 X& W% K" N G
6 B9 u1 h3 ~- ~0 I. D* W* g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' i' l/ _ H: s* q+ I- F# T' |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ t7 B7 e$ E3 I- Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 f8 T2 l! {7 o& p$ ?; B- ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ g% [5 u! G* J4 F# |* s
5 Q5 l4 |3 m2 A; E9 u# B/* assign the tl som board LED-GPIOs*/
5 P) r- ` p# G& L. Ostatic const short da850_evm_tl_user_led_pins[] = {
( Z, f: ~8 q/ s) S5 ^9 y /* These pins are definition at <mach/mux.h> file */0 V/ x! y8 Q# L( Y; \( A# r: _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
~9 @& \% ]2 Q9 y' m t' p -1
0 l# K) R3 Y8 A1 R};
7 k. a& ?+ `1 r- c5 p5 y/ a# ]9 V8 p/ R3 P
static struct gpio_led da850_evm_tl_leds[] = {% x3 l7 g7 o( J3 V' w5 [
{
! {6 S, |& `3 Y0 \ .active_low = 0,. t. r; D/ `! }
.gpio = DA850_USER_LED0,: u, T! C; `! r- h0 m4 e3 g ^
.name = "user_led0",9 _% W+ E4 B2 x
.default_trigger = "default-on",% V; Z. ~4 |# @4 h7 P! k& \# F+ R
},
& P3 ?% j& @; R# w& ^ {. B9 M3 p/ r7 V; N5 E
.active_low = 0,# G" u2 ^$ A& e- o2 ^5 T! ^' D
.gpio = DA850_USER_LED1,
$ V, E8 y& w/ i Q5 P2 T" w2 b .name = "user_led1",) f* {- y' P$ I: X
.default_trigger = "default-on",7 u. `% D& t0 p8 d$ a
},% a& H# R3 y( t: G: M2 N6 g D/ _
{1 E' P( U+ \. b
.active_low = 0,' d0 |% y' r, q
.gpio = DA850_USER_LED2,. ] Z% E" [3 H6 }3 `% J3 e6 O
.name = "user_led2",
: N. C. \2 ~2 s2 m .default_trigger = "default-on",4 C' [+ h" b5 m X
},5 W" [& \- l% v: ~% W; }
{
- N- ~0 b8 `) \ L$ U; v- K .active_low = 0,
1 f' P" E3 `' |; j .gpio = DA850_USER_LED3,
6 F5 R* W* k* x- j; |# S8 Y2 b .name = "user_led3",
! z, E6 k) O! g. Q7 p+ _ .default_trigger = "default-on",
* K& ?: M3 b1 G. H/ p. U/ }, w },7 v3 M/ J0 ]/ c3 O) b1 U
};2 u C/ ^. z" P
& i9 U9 t3 I- e. R2 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( g; w l. G& F/ c @ .leds = da850_evm_tl_leds,
) I) K) D* q5 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& L$ G6 k1 B' j: T; S0 F( I
};
2 [, c! ^4 m9 b% ~2 K
9 R8 O8 _+ C' u8 ?static void led_dev_release(struct device *dev)$ a; A0 q: T8 I, O
{( ]& D0 g; ^2 |& ?% c
};; |; i5 V3 h6 q$ Y' t. k
$ q0 r# l1 c: S$ {) _static struct platform_device da850_evm_tl_leds_device = {
, Y9 C7 Q7 }6 _7 O .name = "leds-gpio",4 y3 ] H1 t4 h& Q' k8 H, o
.id = 1,- Y! G/ o+ f" J M8 j
.dev = {
: k0 V, S5 I g% _. y7 C .platform_data = &da850_evm_tl_leds_pdata,
9 A+ B& f; `2 p Z .release = led_dev_release,
8 n G' q8 y4 |7 w0 ~ }
; I- q, k1 H0 P# k, y5 B1 m. H9 o};
j, K& `5 {5 }0 T+ A, A! ?. R; Y8 B: X4 P% B
static int __init led_platform_init(void)% E# p" T0 v, X: l4 j
{# a! b5 _( j# Y1 r
int ret;0 o8 ?) }, U$ @- ?; w, y9 l0 c
#if 0
4 g: Q9 Y4 Z) ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" q- |) }! n& c7 z6 q if (ret)
* k7 o& u- A3 y) _; c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" ^! C2 t" S9 G+ S, V( u! X, ]. B "%d\n", ret);
+ |7 i+ z2 C4 o& v* S4 h#endif5 x2 E# A2 B, i5 l' V
ret = platform_device_register(&da850_evm_tl_leds_device);- Y0 L2 `/ J, w; z0 a7 p0 ?* Y9 T; s" ~( y
if (ret)5 T9 n% A' S R9 w- P; n; f! K
pr_warning("Could not register som GPIO expander LEDS");3 q6 L- f# |. S! r/ V. B
else
, X0 {& G1 A3 }% p9 U, g printk(KERN_INFO "LED register sucessful!\n");; u- ]' T+ k }3 n$ j
( J# c A- R! H return ret;
/ g6 K) ]8 n8 I4 m* I1 b/ \9 j% v' f}$ m& s3 N( i* {3 a: g9 l# F
% b) C( u0 [$ N3 V- e7 I: Lstatic void __exit led_platform_exit(void)5 m6 b) K4 P+ U" A) b& i' F
{; x+ k' ]3 L7 Z
platform_device_unregister(&da850_evm_tl_leds_device);/ }% r1 S5 k; p8 \, }- J/ y1 D
* D$ S1 o. d7 s, p" v- }; W printk(KERN_INFO "LED unregister!\n");
5 a4 P* Q6 E5 K+ n1 i' I& j}
0 q/ R& X& {9 _$ R, f/ `
( K( z0 A1 \# @ t6 V6 }0 M! hmodule_init(led_platform_init);
* E# |9 x* Z# B& E( l' Amodule_exit(led_platform_exit);
2 _ X. [- F8 Z. |: D8 y3 z. E; Y$ c8 W b) G; l% v
MODULE_DESCRIPTION("Led platform driver");
6 h$ X- ^% P! N3 BMODULE_AUTHOR("Tronlong");
' a" q' I! O0 [$ {& Z* Y n6 b6 \MODULE_LICENSE("GPL");* f1 E9 z3 F3 }. U) e7 p: r0 `; c! v9 B
3 e) a! G. [' V
|
|