|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: a3 v [& z$ [6 S" t#include <linux/init.h>
+ k6 j( k W* Q. S#include <linux/module.h>1 t- v$ _. Y6 A( @6 M% f
#include <linux/kernel.h>
8 s) n9 |0 w4 `! C. K2 f#include <linux/types.h>7 J3 V- x _3 M3 x
#include <linux/gpio.h>/ P/ W: {( t7 s1 x
#include <linux/leds.h>
, z6 K4 Q# Z1 I- @0 q+ E#include <linux/platform_device.h>
1 j( k, B# y5 S+ g, p/ Q4 |+ J. g
. d- m$ \( `7 r8 i X+ B* U#include <asm/mach-types.h>4 p8 c1 U) o9 I! n7 |( V
#include <asm/mach/arch.h>( E# F9 F- d. h# Z4 q
#include <mach/da8xx.h>; K5 K b0 E' L6 e3 J3 V+ l
#include <mach/mux.h>
/ F( i3 M( @( T, C; D, p
- p9 v' T: k. @! p p8 n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( M2 l1 A0 r' y7 A- x/ c+ V, R, Y2 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 h. C6 z' m) s; }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 g% O5 Y: D" V2 J$ Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 O& E/ V8 H8 u9 q) p, C
: O; F+ K6 X5 ]7 W5 V+ U/* assign the tl som board LED-GPIOs*/8 w' l5 a& u5 s3 x! v/ D
static const short da850_evm_tl_user_led_pins[] = {
0 o+ y. m# Z& c" I; f /* These pins are definition at <mach/mux.h> file */
. v8 @! Q: S$ I6 K# j! N8 @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 V! b! B" \* d* P9 m% P$ y5 k
-18 V' Z& ?' l7 O+ o. O
};
: e, u G3 H. N7 \ d% G7 X' R) T
# D4 L) x" T1 d, r8 s/ g4 ustatic struct gpio_led da850_evm_tl_leds[] = {
M' b" g1 _0 \" C( H# t {0 j: I: f3 m3 c* D$ n2 u! ` c/ b; N
.active_low = 0,
3 N. t6 w* J6 j ?: l .gpio = DA850_USER_LED0,8 z# T" T$ k9 F2 u5 w# U) s
.name = "user_led0",$ C; o# {$ d- v ?) E3 Z6 k) }
.default_trigger = "default-on",
% N7 f% N: w# O },
3 ?7 c# n4 i/ l% _2 f {4 d# [+ y7 B$ k6 [7 f; v: O
.active_low = 0,
6 w; z* r$ ^, C2 Y `$ k6 j .gpio = DA850_USER_LED1,
4 v4 Z# H! J# _: |0 T3 B' O .name = "user_led1",5 S" F- \; W. ]6 b0 G# U
.default_trigger = "default-on",1 O; K: |, j- U3 c1 H) i0 W! ^
},
+ l& A$ o2 Q6 p7 V, ]' v# ] {
. u* z: I J$ b& j" q# J" k- T& X .active_low = 0,
" ?3 f) f2 v# Y* O7 P .gpio = DA850_USER_LED2,9 `' N# J3 h7 M+ @8 O8 ^# ]
.name = "user_led2",
. b y0 [2 y& } p .default_trigger = "default-on",& h! O, e6 c# d" J+ w: |
},
' X; W4 O% l/ y' ~ {0 e& Z% `: I7 S( m, Y
.active_low = 0,
( v. I. \/ q) U+ P- o0 T. L1 w .gpio = DA850_USER_LED3,: g0 A8 l7 ^) u3 q
.name = "user_led3",- ^& ]+ F. j( h* U' A+ |, m
.default_trigger = "default-on",7 ]7 [! w" p, O ^! m
},) ] C3 H" _% `0 Y
};8 F, }: N; M6 }" t$ S7 M' J
7 L' o7 N5 y) n# u: ]4 s8 u7 E. j# Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ `( C, t- a3 n4 S8 u .leds = da850_evm_tl_leds,7 W1 b4 ?1 }5 X- r* V# ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ q# v r2 j" w( i( A}; J- Y" S$ d( f& f+ ~! n
* r4 {% d2 b8 m+ I& Dstatic void led_dev_release(struct device *dev)
* [" V: I; l. G( P{
. }; D; X/ A+ j U7 w) J. X: w* @};2 Q3 G& o+ x% h7 S! F
! y: q) a! N) m3 Gstatic struct platform_device da850_evm_tl_leds_device = {
3 v- m! I) y8 |1 ^/ _1 I .name = "leds-gpio",; r! F. L) X# {$ r
.id = 1,( B4 C- q( b E1 Y u
.dev = {4 E, |/ ]$ A+ q! z6 I% e! X3 \5 ^
.platform_data = &da850_evm_tl_leds_pdata,0 d6 o$ H# A% ~/ r+ D! D$ @
.release = led_dev_release,( m8 y& n, v* P* c, O
}5 K4 s% r! y: x3 W' A2 U
};, D2 Y1 U- D. v( g
6 v/ O9 K* ~+ p: ^, `! M; V' O
static int __init led_platform_init(void)1 o" n! Z9 s% r3 e
{, t8 _) {; _3 h' a* `/ x$ w
int ret;
1 G$ d% q6 G# ]. X/ o- e$ C#if 0& }! L6 O4 d3 E& v( c
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 N* r* h4 P4 \4 J( H* b: A4 t if (ret)9 j- |4 R) q( Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: I1 S1 t& c/ h7 V: m "%d\n", ret);1 W) ~+ b& L1 z q# i. Z. V0 U
#endif
6 h; E4 u7 K3 b- Z% p6 s" L2 h- p ret = platform_device_register(&da850_evm_tl_leds_device);
4 y# ]7 N! e; G) ]6 v8 M; O* e7 L if (ret)
' L- ?1 }+ N, L- N- ? pr_warning("Could not register som GPIO expander LEDS");
3 B* n% Y/ ]) `, N( g# Z2 \% x. C. n else& I7 L Q/ X! x# O: c; Y+ p* v/ Q
printk(KERN_INFO "LED register sucessful!\n");: X( }, ]. }. Y5 W- c, ^2 S
4 d3 Q, r: R( X) L9 W return ret;
8 {1 p% P8 c) o+ y8 J$ h, I}$ X: l5 s+ ~8 L- q' o9 k- d
/ e6 a( { I+ y: istatic void __exit led_platform_exit(void)" F8 S% Q' E$ R( ~ Q
{
3 q' n. |1 Y/ [: X, I; z$ } platform_device_unregister(&da850_evm_tl_leds_device);
^% X* A9 x4 D4 V* q& B6 C2 O6 }9 U3 Q! P0 h4 h( G
printk(KERN_INFO "LED unregister!\n");1 T( Z8 K7 T# Z5 \
}1 ~/ ^. ]8 S p! P: U% r8 D
4 a/ Y8 e* R9 O3 m
module_init(led_platform_init);& K! E; v% J- V3 c+ ~% X9 S
module_exit(led_platform_exit);1 D: p) F$ k* P9 C9 l) {5 i
7 D- H1 P0 m8 p, P/ l" C! E& TMODULE_DESCRIPTION("Led platform driver");
( C) v" C8 g; Z0 ]' M9 ^MODULE_AUTHOR("Tronlong");
. l0 _$ m+ {, f; d; zMODULE_LICENSE("GPL"); t9 {( I& {! b
4 ]7 H" [. [" J |
|