|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 |8 N G8 B3 }& T8 v; n7 A#include <linux/init.h>0 y- A h; S8 `: c/ {( I
#include <linux/module.h>
5 y, B/ k8 ~, C- J- c+ [#include <linux/kernel.h># H: N ]8 Y6 y% [ c+ a1 K
#include <linux/types.h>7 @$ o. f2 H% [3 }: L1 Q
#include <linux/gpio.h>: u7 Z! N0 ?. z1 H" N
#include <linux/leds.h>5 @6 Z! u5 R: u
#include <linux/platform_device.h>
5 A) v& ~3 \% K: ?4 N( x6 N' q) P9 M& o+ c5 \- x& f3 r
#include <asm/mach-types.h>4 o$ d( u! X; J
#include <asm/mach/arch.h>
9 L' q9 W* V/ ?2 [5 t! ?#include <mach/da8xx.h>3 g' J; i- U( y3 Z. u7 B
#include <mach/mux.h>
& i5 \2 x0 m% ~ c) ~4 L2 D- b8 M; Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 p+ ]/ q2 M( ]. N( K/ x$ e#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* H" T! r, {, g( Z& w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- |; H8 i" C I! r6 J3 C* F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 U- v2 e/ x- `& |4 Q; E) [3 Y+ G0 k
. |0 w8 Q9 [4 n3 G% e. P, J/* assign the tl som board LED-GPIOs*/
& d ?/ L7 k( z' F T1 astatic const short da850_evm_tl_user_led_pins[] = {% J5 Q: J( A x! L
/* These pins are definition at <mach/mux.h> file */; u7 }( S/ V9 m3 W% b4 O8 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- A2 H# R0 ^, k7 i# P/ h# Q -1
( `: w! T* w, I9 N0 z};; L. U/ ` i% H# ^
6 D5 z9 f: t. P- B
static struct gpio_led da850_evm_tl_leds[] = {+ D. u0 O2 i/ {
{
# d' x" X- A( f3 x6 O .active_low = 0,
1 O1 S% d5 |! x- O2 [$ H' J3 y( v .gpio = DA850_USER_LED0,
0 s" W4 c/ v, s0 F .name = "user_led0",
/ }9 s) d! a9 ?7 H1 p l .default_trigger = "default-on",; \: l9 M! f$ L/ |% ?
},
+ r" u/ O0 r! W- A( N {
# e8 U8 y3 O% L8 `3 f$ c .active_low = 0,
# ~3 Z2 A) }. s7 P .gpio = DA850_USER_LED1,
( q1 L: U6 C: L; q" v- [. P& } .name = "user_led1",, ^$ N/ q: d* G- m2 o& Y
.default_trigger = "default-on",
( [+ S& P& e5 U; B) l6 c },
! @: w. |8 b/ A" w2 V, _ {+ C+ g- P7 R& n, M1 ^
.active_low = 0,
( i# _' E' E3 H. i% C2 Y .gpio = DA850_USER_LED2,
; w3 U! z9 Z' S- B .name = "user_led2",3 [" [4 I8 q6 U {
.default_trigger = "default-on",( ]& Q2 }' ~ J# c8 x: d7 D+ S
},
5 F+ c- B' f7 y1 @: k3 P, F {
: U' B( ~( W7 U m .active_low = 0,
, k+ d q" n5 X! u& Q3 j) j5 i0 I .gpio = DA850_USER_LED3,4 D4 Q; ]' ~- \1 }" l6 Z. F1 V; w
.name = "user_led3",
( ^, r. w: e0 U3 T% U) N .default_trigger = "default-on",7 E6 O/ w0 c# U: \( W' ]- |
},
+ E+ R. I6 a2 q7 F};0 {9 t3 u. W- C
# X7 i# F" M9 a1 d1 U$ Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( J8 y; a) X) J! l# h } .leds = da850_evm_tl_leds,3 u( \/ ~) q$ \2 Y& p) H2 \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% D. @; x4 \* H1 M* @& _$ x};0 I& k# \( C' ^$ L# B/ V
0 n* w2 ?5 X, M. E1 [( l4 nstatic void led_dev_release(struct device *dev) D9 Y8 V, t% c: B/ \: I
{
G! L+ K! }+ G; Q; k};* ]0 @3 ]7 G* G2 d- t3 q
4 U4 g) U: Y5 D
static struct platform_device da850_evm_tl_leds_device = {
4 r' x; l5 |% X .name = "leds-gpio",
) t- M: a# O+ c, p6 n .id = 1,& s7 p' v0 ~8 l# d0 F
.dev = {2 J, ` A/ m# a$ ?8 d6 V% _
.platform_data = &da850_evm_tl_leds_pdata,1 @+ y# H: B5 L% F- H
.release = led_dev_release,$ i7 S" p$ n1 O! Y* ?0 ]
}, Y+ `: M+ n( F9 T4 |/ |! V0 F
};
* z4 y9 X( _( U" _& F1 Y
. G; b/ n* e2 V, {static int __init led_platform_init(void)' C4 @8 v x7 s+ q4 a; T3 H4 _
{
3 L8 {3 h h3 ~! ~1 d2 w1 ^) s int ret;
! f4 e1 }& I. r$ ?% O% |9 g#if 0& @4 Y# w0 M1 X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); \ P# X9 W# }. p
if (ret)6 e B- s( H7 h1 {" L! Z' e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 B) J+ H/ D9 u. j- W7 e0 b
"%d\n", ret);
. }; `% u4 v p; G5 `" h) w3 f' m#endif
F1 t7 N8 \8 t' p ret = platform_device_register(&da850_evm_tl_leds_device);
# J7 ~! ?1 Y6 | if (ret)
/ f0 U$ |" M6 g2 i/ ~ pr_warning("Could not register som GPIO expander LEDS");
; u. P2 R* R. d* |( o else
+ \9 I- b8 Y" v( k, R3 g g- T3 r% G printk(KERN_INFO "LED register sucessful!\n");4 |2 F: y7 W4 w. P
. K1 y+ { W& S. n* R return ret; P: [* `2 f+ I" G4 |
}
7 q! c* Q) C* d2 L
5 d7 R, x4 H8 w; ]static void __exit led_platform_exit(void)( I" `( @; e. n; ^
{' x; `0 y' o" c" K" f$ u6 T
platform_device_unregister(&da850_evm_tl_leds_device);/ K9 A. X9 B+ B; s! j7 X0 P& @
+ |$ O4 c% W9 Z' N( r# P printk(KERN_INFO "LED unregister!\n");
9 |! Z( ^) { @( s+ O* c( M}' u! [% J9 P/ k+ P1 L& R
* [+ w( l% U5 F# L' l9 X% |module_init(led_platform_init);: h) }% E+ m/ k5 y2 s
module_exit(led_platform_exit);
+ p1 F" d4 X ~8 a+ [& L }" A+ o, g0 U9 k
MODULE_DESCRIPTION("Led platform driver");/ y& [: P7 W# @7 |& z
MODULE_AUTHOR("Tronlong");4 X# v* a+ f9 S/ L1 `
MODULE_LICENSE("GPL");5 R9 v3 l1 E8 {5 o# C8 s
- W) _; ? E4 n' G! A' Y/ s: \ |
|