|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 {5 C+ K" D, s" z# n6 L#include <linux/init.h>% r3 ?/ g5 n e; J5 j3 H! n
#include <linux/module.h>
7 `, J+ M( D: W7 V#include <linux/kernel.h>
5 h- f; Y/ j- l8 }# u( E0 d#include <linux/types.h>& J9 f9 Y# F6 Y& r+ M* w
#include <linux/gpio.h>
8 I7 s& W0 J2 e! R2 A#include <linux/leds.h>% N0 ]: d2 T* t/ W0 @5 H% `! T
#include <linux/platform_device.h>! {$ d2 M+ O, v6 f
& p& a. g4 b. e7 c8 Q
#include <asm/mach-types.h>
6 [& G7 J" q8 t7 r+ ^9 R#include <asm/mach/arch.h>
1 `1 Y9 i& F7 M. u* u#include <mach/da8xx.h>( |/ e" g; z( X# T/ o! J
#include <mach/mux.h>8 B+ a3 z8 i4 O- L# B/ D" D3 A
" g4 h1 {: V# J& d. z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 q% M' n9 T3 R6 M+ d5 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, N! h- i: [, p m9 w' ^( e& E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ \( ?4 s7 L6 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# c2 j: \& P$ K) `6 k* l) U
: l. y8 a7 d! Y# D+ ~0 |
/* assign the tl som board LED-GPIOs*/
7 e) V W/ T; S( a4 _; v4 N% G' istatic const short da850_evm_tl_user_led_pins[] = {$ M9 V' Q8 ~8 l* g+ G" M
/* These pins are definition at <mach/mux.h> file */
& \) s5 o, W; E0 } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% n. r/ r, G* g; e7 _ -1' W7 m' s2 G0 _- y2 H9 `& l
};; s* u* B/ t( _* {5 k
: J) t1 [& a9 f2 Y( C1 V& e! lstatic struct gpio_led da850_evm_tl_leds[] = {
9 X& X' L+ e+ z {: J3 n% ]0 B2 i1 Y5 `
.active_low = 0,
4 \4 l6 N5 g1 w- s8 X( W1 M4 P .gpio = DA850_USER_LED0,* {( c( ]3 M0 [& Z
.name = "user_led0",% A. T( P# X, l8 o7 r0 q) k) ]' r
.default_trigger = "default-on",
, W& @. l% h- V9 x! N( J: a. r },( B p2 S' z/ Y+ ~7 d
{
. p5 K4 A0 p# m. y1 N .active_low = 0,
3 d3 E$ f0 [$ s8 J W E6 B .gpio = DA850_USER_LED1,, c7 t7 u0 a8 L3 R2 R
.name = "user_led1",
c/ P1 W; o6 J .default_trigger = "default-on",
u# x3 A- k4 _ K7 b },# Q; Q7 f8 z7 s1 D
{
! g! f0 R+ W5 c- c .active_low = 0,( W3 F* {6 i- n. Q# H( ~
.gpio = DA850_USER_LED2,
/ U: w6 c2 Y! ]. |% J# l .name = "user_led2",5 W& k) c6 n9 }0 z0 a' e1 t
.default_trigger = "default-on",8 K4 N! m. @3 X. s( k% Q& Z
},
! l: O: m- R! v7 P$ Z3 K {
9 `* e+ T- d8 r$ \0 ^ .active_low = 0,
' c* I0 M! J2 W' j% l1 Z; Y( R) F3 [. b .gpio = DA850_USER_LED3,- s& W; b4 m) j; N- v s
.name = "user_led3",
5 q8 L5 @- J3 W3 h w: O .default_trigger = "default-on",
; h) w' ]+ d! h* j },1 @0 A: ^! ^' e* R5 D
};
; P. Z$ I+ B5 l# v4 P- E
; D8 k! F/ \% b7 p6 H, Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 L6 b T) Z9 q2 Y .leds = da850_evm_tl_leds,8 N3 p8 }/ I0 ^9 N1 {* M. S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 l* }2 l N V' m& |0 o, y+ {
};
5 q8 y3 X) T% b9 b. p2 U) K9 s f. u" z [0 b
static void led_dev_release(struct device *dev)
2 _ q) q" C4 P# K{
9 W4 {) \+ ?4 V0 z- S3 r};
7 v" k! B$ A9 c5 s( _, F8 w& B) y; h5 {5 e" v* d, s$ t! W$ _
static struct platform_device da850_evm_tl_leds_device = {
4 u' ~2 ~ p" N0 {$ X% j .name = "leds-gpio",8 o( @% l( b7 D' A# D c
.id = 1,1 F6 w4 b, ?) u
.dev = {
; ?; t* F. N( A$ o+ |9 H) y .platform_data = &da850_evm_tl_leds_pdata,
3 g" H% T' n) ^5 X B. k9 u .release = led_dev_release,( t+ @% U' R& C2 s, p
}, c" i2 k2 D1 [: n5 c; a$ E
};
2 w r4 c0 h: W; l- d' j" M3 U2 S4 w- n$ k% D( `& I, U
static int __init led_platform_init(void)
& ?4 r6 U4 |7 D3 L{* N* ]; g* A( _6 _9 y
int ret;% ]+ X9 C7 E9 b. ~7 |# ^/ v; O3 F- b
#if 0
4 f& V% d' w' U) w; _( M0 a' v1 Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: V4 T: u4 M7 b0 z E, P: G if (ret)3 x H- W6 O. r7 A1 ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 s; x+ V4 Z2 l5 [, h h- j0 r
"%d\n", ret);
/ s: b7 a, V- C T* T- D) n, ~0 ?#endif) e$ H; _# {. ]! h& ]& n
ret = platform_device_register(&da850_evm_tl_leds_device);" |3 @" _4 O4 J9 i
if (ret)
9 q b. m' x; u2 L- F1 v pr_warning("Could not register som GPIO expander LEDS");7 M! ^+ @# ` A+ s" Z1 J
else2 ]! w# K; s. c9 S2 ~5 S
printk(KERN_INFO "LED register sucessful!\n");
8 [7 L1 @9 [# s) L5 S& ]& M( _; K; Q( l- i$ \4 l" }) p
return ret;7 _! |) K9 a" A$ v/ I
}
6 N& h( M, Z: ^& X4 P' d
i) F3 Z! u4 A. L& m9 Ystatic void __exit led_platform_exit(void)
( x" e% ^# K# j% I1 T; z" T{
% w3 N9 a/ k2 S" s x0 ^7 Q D platform_device_unregister(&da850_evm_tl_leds_device);. W/ B0 P( R6 e7 Y+ i
6 A( _6 S- l( \/ x) A printk(KERN_INFO "LED unregister!\n");
7 [! w c) ~- `; ]" w. b}
) }* p2 z7 }1 _5 |" S: Y
, R5 B. I. u) l% E" z6 @module_init(led_platform_init);9 J, R7 E- ?& A$ t+ t8 M
module_exit(led_platform_exit);
4 Y) R5 k0 \: p/ n- v5 Y: d/ t9 K9 Q) z; ]& K1 o7 G
MODULE_DESCRIPTION("Led platform driver");
8 u# R8 V6 Y7 ^* q6 yMODULE_AUTHOR("Tronlong");
9 z: c2 B9 {8 L OMODULE_LICENSE("GPL");! ~# p% O8 B" M/ O* A) c
! f$ d2 d. U) u# P0 X4 I
|
|