|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 f- A& |7 X9 W0 w- ?+ r#include <linux/init.h> i' }# z+ m( h* W" }2 t& m1 }
#include <linux/module.h>) f+ T/ J' a$ d% T% C0 h; u& R
#include <linux/kernel.h>* ^) p8 H6 A0 L6 B5 p6 N" a
#include <linux/types.h>% o V S9 _6 N# t- c4 Y
#include <linux/gpio.h>
3 o2 T) W1 l. X4 N#include <linux/leds.h>
5 ]2 b: ~6 ?9 W( ^, ^2 F! h#include <linux/platform_device.h>! F3 _% Z5 n* k: K
2 ]& `9 l# B6 p; d6 U3 B#include <asm/mach-types.h>
; {' \, ?, P1 E. K% i O+ d( b#include <asm/mach/arch.h>
( l$ Z# S1 U/ t3 i#include <mach/da8xx.h>
0 m6 v) {' @4 D+ @3 G4 o! Y/ S/ L#include <mach/mux.h>
* m- I& y2 k" _: h
( |1 l% Q1 @" K* h5 s5 f4 h" e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" Z; r/ h: C8 ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 w3 C% V/ S0 d/ Z. m' L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# i6 C2 B O" S& |9 _
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 n. C' w- A$ D Y p, x# T0 n
! P/ p. T# P) q% P3 \( N/* assign the tl som board LED-GPIOs*/. i6 Q9 O O! j. ]$ o" _
static const short da850_evm_tl_user_led_pins[] = { G: w8 Y0 r6 r/ q) Y- W
/* These pins are definition at <mach/mux.h> file */! C, E% ^4 @, D, y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: m; K2 c i% V( X- ?: u -1
6 V. r9 W( s; z% G};
3 F/ b0 q5 f* C! H
( U5 r h. L. x3 _# k* {static struct gpio_led da850_evm_tl_leds[] = {0 H3 y2 T3 l3 {5 b8 f
{0 Q7 F" |! b" |$ T# P
.active_low = 0,
( k- D! B Z( d% X# [1 w" H4 m& h .gpio = DA850_USER_LED0,( X" B- [- v# E5 q* j$ ~1 ^
.name = "user_led0",
* u" [( Z# `4 Y" a3 U# C" P .default_trigger = "default-on",
* }2 i. t3 r( w# A8 U8 x, Y7 i },
: X+ y6 C4 z# B2 I p {
: D( R$ S/ o8 O/ w- x1 M. v+ g .active_low = 0,# w6 e4 _; R2 X9 w' L
.gpio = DA850_USER_LED1,
( u, t# \5 j& _/ I; k* _" V5 A" y .name = "user_led1",
9 t% o; b7 d k0 w* x7 y .default_trigger = "default-on",
: A8 G& i" G% g& h- n },
" [5 B M+ H Q" G! ]0 v4 r {
( b1 j0 g. m3 k# R3 l .active_low = 0,! i( h5 W* ?4 N3 C& j, S+ p/ N
.gpio = DA850_USER_LED2,) _+ [& g3 O/ @' @
.name = "user_led2",' ^8 `: t& z% k+ T
.default_trigger = "default-on",. @0 q+ f6 m" L8 S3 V: ^
},
8 y5 P4 Z) R9 g) e) Q, }; J1 Q {- P% B8 A: P# I" w, y+ K/ b
.active_low = 0,
9 h; i: L( ~; w3 \+ Q .gpio = DA850_USER_LED3,* h/ a- Y- u' z: G0 e1 M' d
.name = "user_led3",
$ |0 O, x/ u$ f4 [ .default_trigger = "default-on",
/ I& @' J5 b- m; g },
! y# d1 j2 `, t0 {& y1 ]};
8 v" F0 i1 W% y# k, i% _" i' Y+ u3 e% Y/ X6 ]$ J% Z* L: x+ c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 b# x, }; D h% y( v
.leds = da850_evm_tl_leds,
2 L3 H8 _/ p$ C! K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: _8 C4 x/ B' C; f};
" _% }/ P; L; L. I$ m8 p) R
/ y; g3 g6 B3 v7 [) hstatic void led_dev_release(struct device *dev)' c$ n1 ]% Y* F, O6 |% g
{. r4 H% L5 }% F0 n
};
+ L% U4 q/ |) f9 T
" o7 z. h/ T P; Vstatic struct platform_device da850_evm_tl_leds_device = {
) a. f$ X2 Q3 G7 I .name = "leds-gpio",# W f* t8 R: P' n, C
.id = 1,& n h8 L, O/ n1 m' e9 T3 n$ @
.dev = {
% I6 l( K) B$ ?; o% r& R8 x .platform_data = &da850_evm_tl_leds_pdata,
5 G, e$ ^& @, s .release = led_dev_release,4 N6 K7 Z7 W+ q5 q, @& v1 E+ \
}
9 K0 z$ c/ o3 n};
! k7 ~( f4 S5 d+ ~/ {* C( p
n ]0 D( k( T: Y/ Fstatic int __init led_platform_init(void)
& c+ Z+ L2 W3 T* E; x- ~. n$ ]{
- y6 ^: ~( M$ q) ]$ l% U9 a int ret;
( b1 W% ]) G7 Q#if 0" d+ c! ?. U5 B+ E" [) O0 }1 ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" ^' [- V& \+ G5 x, @) k F5 f if (ret)
7 E5 R8 K) ~3 v; o1 ~" x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! T6 U* h' Z. i* X8 i2 `2 c
"%d\n", ret);
" M% _/ D! ~$ a/ Q#endif7 Y2 ?% e4 X9 @; b. v6 R
ret = platform_device_register(&da850_evm_tl_leds_device);2 O5 G2 s# p. Y# x* m
if (ret) `3 j7 n* \/ }
pr_warning("Could not register som GPIO expander LEDS");
, W/ }3 Q4 i( y1 j" ~& K8 b# @# H1 s else# H9 p t# N/ Q
printk(KERN_INFO "LED register sucessful!\n");
g5 E4 R" Z* }6 C: j! R- L
8 t* ]" \, m1 E, l return ret;) U" E- K. e( c- S- R0 q9 {8 @ |
} J; v" k0 Y1 E! E2 [ m8 d3 k
+ K- o0 {) s* Q; Tstatic void __exit led_platform_exit(void)
5 X" \. R' D1 Q- S: V3 b{) e" A0 b$ q( r9 {# o0 W) l
platform_device_unregister(&da850_evm_tl_leds_device);3 R+ A* p$ l) I/ ^/ @! g/ v
: {2 q* B9 y/ d: }1 y+ E- R printk(KERN_INFO "LED unregister!\n");
6 {, ~' ?( q. Z}2 C* \& }' T% W! @% K# E
3 T: t. a' {4 S) B! g' a5 C- V
module_init(led_platform_init);: @$ P7 t9 _5 v2 d) L
module_exit(led_platform_exit);4 o! r0 K' i3 \* k
. F" ^4 a& a$ N3 a @* cMODULE_DESCRIPTION("Led platform driver");! C/ Z/ T- N0 \
MODULE_AUTHOR("Tronlong");, d( x, ^/ x* p
MODULE_LICENSE("GPL");6 {; `% o1 k9 W% f; k6 l. M5 [1 q
* J- j6 T) w- I8 {! \7 `: n
|
|