|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! j7 z' D k/ M8 E. D; a
#include <linux/init.h>
/ \, v" }/ s- S' i% ?2 q* M/ F#include <linux/module.h>9 d9 M' O5 u r% Y* e6 B+ w
#include <linux/kernel.h>! J5 j r* v! i2 z
#include <linux/types.h>! P9 Y- K& R, {; ^) W {
#include <linux/gpio.h>
: |. C5 ]# a6 l1 o#include <linux/leds.h>
1 ?4 o6 |1 O9 { c#include <linux/platform_device.h>( n. p3 j J0 K3 M: t) W2 {
4 U; {6 b' {6 N4 J#include <asm/mach-types.h>3 i/ o7 P' l9 W1 k. Y, U0 I
#include <asm/mach/arch.h>
9 B% b8 J/ m$ h, m. \6 S- n#include <mach/da8xx.h>
9 { L# |* o. K8 y0 E6 U1 B2 z#include <mach/mux.h>
u& r$ x+ G+ s1 V3 s" p( N. I- s
. f) c' q6 U2 ?" Q, F2 ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), r' a3 d7 J0 a5 w) ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 G9 ?/ ~- _( D1 a. G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 } a# } ]6 i2 a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 |( i9 @/ t, }; ^6 r: N
/ ^0 r) c6 W, Z
/* assign the tl som board LED-GPIOs*/
# \: T6 j/ N; Kstatic const short da850_evm_tl_user_led_pins[] = {
3 G1 [% K1 W5 S: ^5 Z! A6 b /* These pins are definition at <mach/mux.h> file */% ]2 d% M- V S% F( o( _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; {2 k1 ]% p# {* p! Z( ~5 j; A
-1( S0 r3 H3 C' V0 q* z) E- r
};/ W6 N) H: a& E+ Z t9 w4 V
2 C5 N" V! ?" }, p; z
static struct gpio_led da850_evm_tl_leds[] = {+ c: z$ l" N7 _% i& L* C
{
# l8 ]( {, X; a9 h .active_low = 0,% y- d" m3 L7 k' b/ s, b' O
.gpio = DA850_USER_LED0,4 ?7 a% e& P) N
.name = "user_led0",3 ?0 A2 n2 U! h6 J) j# Q9 Y0 A
.default_trigger = "default-on",* }5 Y$ [# z" i/ Q' W; u
},. n" ^1 i/ m. n0 M6 _) l: a
{$ Y% e2 A8 J& B# G! |
.active_low = 0,
* O# D# I9 a$ e2 q4 l) ?3 |. z .gpio = DA850_USER_LED1,
3 U2 G0 M5 @& P# L* O6 x2 e .name = "user_led1",
|( T$ e9 {- c .default_trigger = "default-on",
% c- G* d' S/ m* k5 v8 | c1 a },+ z$ [8 Q% _' f p, A- G
{7 |- \% e/ K) M5 ~+ i
.active_low = 0,+ A- l7 ?" t# s$ j
.gpio = DA850_USER_LED2,
1 f6 B3 \0 O, G+ j7 z9 S4 R, R .name = "user_led2",5 X. S Q9 k: K
.default_trigger = "default-on",% e( q. `9 O- K0 L1 k( M! x, ~
},# M8 u8 @( {5 @, k6 S. |+ u
{) d- N4 Q& y, T$ _
.active_low = 0,1 Y. {7 a9 E) b* R4 h, T4 g# Z
.gpio = DA850_USER_LED3,
+ W; K2 I! [+ Z! ]" q! x% J( z# ^8 [; \ .name = "user_led3",+ s, _* }5 W- g& r
.default_trigger = "default-on",7 k7 Z C- ?) Z. _' K/ b9 A% R: ~
},# Y& R& l7 t+ V5 ]* I) E: h
};
0 `# C4 K# E2 Y+ R# [
: f" I3 x' a# D( t3 `8 ` S) Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 g0 P2 w& b5 t .leds = da850_evm_tl_leds,8 n/ X1 a$ R* x# v) G: B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: }3 }' C7 N6 ^/ K3 A2 H! ]: f9 m! A
};8 E9 k0 }9 \; M! P
6 M$ j& S0 |: q% d
static void led_dev_release(struct device *dev)
; u2 ], e- N/ M" T2 Y9 s$ S0 r{) o( S1 l2 u- v8 g9 Z
};
/ |. \+ O8 D; e' v2 u* ?: H+ J8 T. F0 p v3 \9 q( X7 {; z
static struct platform_device da850_evm_tl_leds_device = {
1 x+ k% G' c: f: O$ H6 j .name = "leds-gpio",
- d$ E; ?2 W P- w0 R .id = 1,
" L& H" V) F' V) m1 j .dev = {. E6 D) K8 N x5 [
.platform_data = &da850_evm_tl_leds_pdata,# C2 g/ s2 }* N6 d3 B4 y3 V$ F
.release = led_dev_release,
$ u) }( i% ~$ Z% M }
5 [2 c' B3 y& u# E z; o/ d$ o. G};
" @# k) M' y7 z( r1 A+ K7 o5 v# s6 d
static int __init led_platform_init(void)0 D. N' f e1 M% B
{
9 j% P" Z2 D0 k& ?6 P int ret;6 H7 o' N* b% u7 y
#if 01 w0 U0 H U& P1 j/ f5 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
[. {' P* k' p( g; j1 x# T, d o$ [ if (ret)- V. o4 A' p* P0 o+ V5 U2 u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# Y2 M# v' c7 C* D "%d\n", ret);: k; J0 n2 d* b+ _5 L
#endif% t6 u; K# _! T: r* M. V% E1 Q
ret = platform_device_register(&da850_evm_tl_leds_device);
0 u( w8 y" A* \& l& }' `) [" E if (ret)
6 G x$ S; w, {: [ pr_warning("Could not register som GPIO expander LEDS");
0 Q' i( r$ _) d0 U3 P else- {9 k9 c/ O& C R6 L. I# N& {+ Q8 p
printk(KERN_INFO "LED register sucessful!\n");* [. @" {: F/ ?" g# v0 c3 a
6 D! Q% n) m/ Q: ]* G" E# L* f
return ret;
8 H' m9 V1 ]; M5 N3 ], l$ I}
4 L! S6 H# i! E- N3 i/ L1 |0 C- t% l: ~* I1 W" A3 w: S3 W
static void __exit led_platform_exit(void)
5 N2 l9 O1 z. d{% c4 v8 V+ L$ Y1 h
platform_device_unregister(&da850_evm_tl_leds_device);
1 z8 S6 j/ u/ |9 u7 K0 G
3 H6 p" g! ^0 O6 R printk(KERN_INFO "LED unregister!\n");# x( x1 `1 X' B$ r: A3 X( D5 R/ m
}$ l1 `9 K% _0 I- d, C, Y' h
* n- {2 L7 \; R1 E8 E5 ], Qmodule_init(led_platform_init);
. [" d3 w# h/ m4 }* |9 x' Omodule_exit(led_platform_exit);
$ U+ [1 u8 N+ K0 w( n& |
8 h/ D& D% }6 v7 Z$ R( M& w! zMODULE_DESCRIPTION("Led platform driver");/ ~ G# ~1 S! V8 Z/ S: o! l
MODULE_AUTHOR("Tronlong");3 n* p5 `' l/ p, M
MODULE_LICENSE("GPL");
1 d, K7 e% l1 Q" ~. o9 n# y# S# e/ F) j* e' q3 t
|
|