|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
d3 d* @: h, J/ A4 V3 B#include <linux/init.h>
, \ z- g- p& t, h4 y9 ~4 ? f8 \#include <linux/module.h>& R3 a _& m1 b: F
#include <linux/kernel.h>
% {2 ?2 z- J' e4 ] Z# Y#include <linux/types.h>
1 T7 H& k! u2 ~0 T#include <linux/gpio.h>
/ x* }% h5 X/ P0 e2 F' M) T0 t#include <linux/leds.h>
9 }( }9 O0 b9 H+ N3 @#include <linux/platform_device.h>
; b1 E5 U% m6 f0 Y; J
0 l, ~' J7 B m+ m# q0 ?* k$ C#include <asm/mach-types.h>
, j. {% K+ r& x#include <asm/mach/arch.h>
; v( {, A: Y# h6 M4 I" A#include <mach/da8xx.h>1 _/ d P" `) h% L* v
#include <mach/mux.h>3 j9 g5 R. C' V' ]# Q+ y- K8 m
; @9 ?: h! G2 m, S T5 {8 Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; Y4 R. }4 i& x a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ e5 D& @0 [$ N8 z& ?: n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 u# t5 U: r6 G. r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 v* P1 ^* d& g$ h: } U) V& u
; D' p6 R6 |, A5 P/* assign the tl som board LED-GPIOs*/
6 B+ \. x$ l) S" q* `5 Ostatic const short da850_evm_tl_user_led_pins[] = {5 u r8 m% t s
/* These pins are definition at <mach/mux.h> file */
1 c* X t9 B+ q" ]' } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 M' W, L# q9 A# p- z9 i) A6 x7 e
-1
k2 n8 Z' M" ^5 w};! a: D, |+ t/ n8 x
; A# n/ _; Y/ Y# K# G" `& m8 pstatic struct gpio_led da850_evm_tl_leds[] = {
) E3 N: S9 q @8 x- _2 r {
* l2 n* C% x0 u8 f/ C f .active_low = 0,
$ _3 Z+ w3 _ w7 C) E; T+ i .gpio = DA850_USER_LED0,
( k5 O+ X3 \5 B V5 W0 _& ], B .name = "user_led0",
/ V5 I# Q: ?& C* y( U% Q .default_trigger = "default-on",
2 }' j. [6 N; p. I5 @ },
2 e& t' O* S- @1 T" G: k {
7 {# U7 g9 h" k& p$ N4 o5 Y .active_low = 0,
) O8 M3 X* N/ E4 ]" p& G' A .gpio = DA850_USER_LED1,) k7 R7 l" {6 q
.name = "user_led1",
% S. K9 z+ ?; [; g! l .default_trigger = "default-on",
' g- \( U4 h6 u- D$ `8 D- C T },
* A) d: _6 e; R C2 h# [( | X {1 C: _/ f( x% O6 w5 \' P& N
.active_low = 0,! V" U- N- |4 e0 o# h
.gpio = DA850_USER_LED2,& `3 X/ r. e3 x
.name = "user_led2",
' x2 Y' K) m# E; t6 g1 O- O+ R .default_trigger = "default-on",3 q3 r+ G, ~ e2 Y% P
},
9 ]/ M. h; i& V8 ~- G {
! H, J H9 }$ d5 w .active_low = 0,
, @* I! |- `3 R8 E q' Y. f .gpio = DA850_USER_LED3,( B& X# W; e7 W- n% S+ j$ Q) c
.name = "user_led3",
% U7 }/ i; I8 B4 [" K7 V .default_trigger = "default-on",
6 P& l3 o2 {! }0 I9 Y2 L. }, a- [ },0 K& Z w4 }9 l4 w2 |$ S" s
};/ s5 o7 B7 j! V/ ?1 l+ }/ E
9 L7 N. H i2 v- fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& Y+ M' T3 M; t0 X1 u
.leds = da850_evm_tl_leds,
' j6 C/ W9 `/ i2 l! I4 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, l- P4 h9 [1 D$ A' f};
+ @$ d2 \, _5 e9 k) c
f) z }2 X5 G% J* ?static void led_dev_release(struct device *dev)
" ?, _' x- }& s9 H2 Z$ ?! j{
8 J9 B& @' e0 R5 F1 o};
; b, Z/ [' t3 N/ V: q. q9 }
R8 a9 Q* c3 l9 l+ u. f3 \; [static struct platform_device da850_evm_tl_leds_device = {
3 z' X( }' d" ~) ~$ _" l' | .name = "leds-gpio",8 t" a2 K$ M" |2 K4 m2 K
.id = 1,
5 w- v& T6 f5 V( `9 a" A) _- q# u .dev = {
) J( n8 m+ K2 }3 F" l .platform_data = &da850_evm_tl_leds_pdata,9 w9 G: _4 ?$ c4 ~ R3 d: w
.release = led_dev_release,3 |/ `. j& R* B
}, Y" E; e0 @: o9 R6 T1 | p
};; w# ~: s7 c* ?; P- @
. K q& P- g& r _/ e6 wstatic int __init led_platform_init(void)
8 [0 ?" Y+ R& I% X, n3 k7 z{
- M+ |; r* k$ H! a7 A k int ret;) a6 r$ o5 L+ x( l
#if 0
; u% |" b; o K- K, w+ v6 u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 F; _: e# I, D4 d if (ret)
' _- R5 k, q$ S" Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' ^; ^0 Q- Y x: T$ ~2 n9 c
"%d\n", ret);- O$ d( h1 N' k
#endif! `9 O" [+ Q% U# ~+ v0 f b
ret = platform_device_register(&da850_evm_tl_leds_device);) W8 ?* K: j' o
if (ret)
8 V1 P! p3 ~" g6 P4 I pr_warning("Could not register som GPIO expander LEDS");9 p. R& N& i4 c, b3 h& F& z& T5 _
else
8 v/ y2 c* Z. h$ x5 k printk(KERN_INFO "LED register sucessful!\n");. o8 H% k8 @, T1 T) E! t
( u1 T6 G+ D8 c5 y# p ~9 G+ k5 H; h
return ret;
4 a6 [1 n/ |* z7 i}
2 u' k4 D6 D+ D t. h; M
8 [* E; `1 l" k0 E6 ~static void __exit led_platform_exit(void)
- i1 [ S, e( ~( ` x2 ?( i{
, h% i5 t0 h( l6 S3 e3 e! \ m3 M platform_device_unregister(&da850_evm_tl_leds_device);
* G7 a4 `. a) |7 E o7 c
6 d# A6 i3 G7 g Q5 [6 q0 b5 z printk(KERN_INFO "LED unregister!\n");) B* U+ x: K2 Y
}4 N; ^( g2 w: N4 g9 C7 ]' D! }
. M/ p5 V- ]$ Vmodule_init(led_platform_init);% W1 {$ C+ S; f2 }; t' g2 [- d% L
module_exit(led_platform_exit);- I( A" |6 N# o. ~ v
$ Z5 k4 V( R' Y7 ?" g; z
MODULE_DESCRIPTION("Led platform driver");
! _) P. G3 F5 Q( m. S+ p8 ~MODULE_AUTHOR("Tronlong");
/ |5 O [5 u' ^& k1 n9 z7 o* q* Z: mMODULE_LICENSE("GPL");2 {8 S0 j# G1 m2 u6 y9 m
( D, M' f P- L; q) V$ W |
|