|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ g; _. S4 |0 Y' v+ Z5 w0 j
#include <linux/init.h>
3 W! q# V8 C9 l0 G0 v$ T#include <linux/module.h>
# @$ C5 a3 p- u3 Z# b, r! l. S#include <linux/kernel.h>
, y( K: z; v# `) A, Q#include <linux/types.h>
! v6 B9 i$ f) ]+ w1 G9 I#include <linux/gpio.h>
; S4 W. h& l) G" M#include <linux/leds.h>, O! a4 [) }" o+ A: p* \
#include <linux/platform_device.h>
9 ]. F) {4 \" ~7 p; M. \
/ W5 y* L; _1 J. S; N+ R4 o0 y3 d#include <asm/mach-types.h>) ~* E' V) E8 ~# s
#include <asm/mach/arch.h>0 n* K/ E. f9 l. h8 Q6 x8 k; q
#include <mach/da8xx.h>% S, D5 y t p* H# n
#include <mach/mux.h>
' j0 G9 {* Y/ L- d) @4 j6 g ]( F( X& k
2 _3 S; t$ L' y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 Z3 v0 g+ x5 S. F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 K2 ?$ H- l% z6 f C. x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( i$ u9 O. [, u8 D) ~) [+ G4 g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. h3 E8 C8 W! z# h1 ~; ^) U* X
2 `% W2 w6 E' ^/* assign the tl som board LED-GPIOs*/& @3 B ]: m# a/ C; o
static const short da850_evm_tl_user_led_pins[] = {
( [5 n6 b1 N6 s) v6 p( z# U /* These pins are definition at <mach/mux.h> file */
6 \5 f2 ^& }: Q5 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& f" \* ?. y* p: m/ q L a) q" M6 h* ~ -1+ J, J/ w) ^* L' H1 Y% Q K
};
: R2 G" d5 }6 C) {. p/ O! Q- _! w1 E9 v
static struct gpio_led da850_evm_tl_leds[] = {
1 q4 U; C" b" S: {. { {3 Z# `; w& B F4 ]
.active_low = 0,5 n# X4 N2 T& l, _( D- I
.gpio = DA850_USER_LED0,& B# B( V! Q/ p+ S, w, C
.name = "user_led0",, [1 @; H; S& O. s
.default_trigger = "default-on",
- \2 _+ z- k) Q# o' `( b },
+ W# E$ F: s0 p5 J- Y { D: V7 s2 u( Y3 g0 Q. ?) o+ I
.active_low = 0,
! Z- y1 _% e$ x6 y" h8 u; r7 w .gpio = DA850_USER_LED1,
0 f' b# B% E' t8 D: l) a .name = "user_led1",
9 R5 b1 P2 s% x) X* K" D% L/ f' v .default_trigger = "default-on",
6 g7 O2 }# I% Q9 o) W },
2 f1 J5 A+ |2 B7 x {/ n9 [5 r( ]; y: m
.active_low = 0,3 D4 y% N1 z2 s- v: W2 _
.gpio = DA850_USER_LED2,. g# L1 B0 G. c5 h
.name = "user_led2",
5 F* @; B; |9 I .default_trigger = "default-on",) O& t$ v$ ]% a2 s! C
},
% F% w; a& v# T: V6 x {' f7 B( |1 Y4 F7 V: f
.active_low = 0,/ W: D( U# s/ E5 R
.gpio = DA850_USER_LED3,! f1 G, L2 _3 o1 [
.name = "user_led3",
! O7 n$ | j! ^0 q7 v .default_trigger = "default-on",- l6 E1 l: z; G# N" r W: m
},4 i; A2 d7 f( s& F& |, H% }
};
' H/ o. t, ^% L2 A$ R# Y. i# @, w. m" P2 D( c% Z2 T1 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* J, @0 W6 z7 `, C# o0 g .leds = da850_evm_tl_leds,
) j3 |% a; M+ n* d- }; d .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," Y& I9 c1 A' {3 D4 b6 {
};; K$ m4 m5 @# v7 ~6 j- V2 x
, k* J( ~- c- U1 `6 ]- F9 |2 Sstatic void led_dev_release(struct device *dev)
' N/ N6 I& I2 [8 r9 x6 x{
2 @! N+ }3 H3 V( d};
% f; F+ f) z8 e8 { I
" y4 Z# n# {4 k) pstatic struct platform_device da850_evm_tl_leds_device = {9 ^* _3 T9 M- a
.name = "leds-gpio",
" `* S/ s. ~7 K! }% V5 _ .id = 1,9 Z" }2 P+ ~1 b! l5 {
.dev = {
' h: s" w# o& t' R* i+ x8 E .platform_data = &da850_evm_tl_leds_pdata,! B3 k# W. A. R7 D
.release = led_dev_release,
4 M, Q' Q( {) P' G0 m# |7 G: @5 \9 n% ~ } q: R: r* X) V
};
3 k* X" R% G3 D/ Z- w$ t# V+ @8 K$ U& \# \* t
static int __init led_platform_init(void)
. c6 ?. O8 \4 w" H9 A/ l{$ z4 g7 {9 T: Y
int ret;% Z& [% p+ }# O K1 o% s+ ]. q
#if 0+ G/ u' R8 ~+ _- g
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 ]3 g2 \/ p% ?9 g5 p if (ret)
8 c$ J7 V" ^5 Y8 M! d0 A2 }. }& k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
N$ g8 g+ ^8 l, t- A, V "%d\n", ret);
1 |! z# b8 I& a! C. P+ R0 T1 C#endif
9 g) ~0 _# o$ _, \- g/ F* w; p* _ ret = platform_device_register(&da850_evm_tl_leds_device);6 Y! o8 W1 i4 {8 X0 F( S5 o
if (ret)
5 m6 r9 H/ @6 S( F& n' [9 I pr_warning("Could not register som GPIO expander LEDS");7 q) m% c) s4 G/ m0 \2 y
else
. q. I0 {, K2 H% n: w2 p printk(KERN_INFO "LED register sucessful!\n");
* J% M# }: t: V) O* z* N. ?" {- U1 }
return ret;
& ^* O; o1 k2 i1 H% M}
+ @( |# P: G1 l! d2 X; R$ Y$ I4 c3 B+ C
static void __exit led_platform_exit(void)
- a: g2 |" B& K{
0 _" p9 `! f7 N$ Z platform_device_unregister(&da850_evm_tl_leds_device);
0 Z# P7 Z, Q9 A
5 J4 @* z D4 T6 m, d9 z printk(KERN_INFO "LED unregister!\n");6 K! H" T5 `2 s/ x
}" {9 F( B$ a# k- E5 ?2 i
6 |+ r% Z; e' Z6 `
module_init(led_platform_init);2 z( o( k/ R) S% x* R! W* }
module_exit(led_platform_exit);
7 I) |9 R+ N* c# H8 x5 f
2 Y* p4 B1 M& lMODULE_DESCRIPTION("Led platform driver");
2 N) V% j0 s1 C( g1 \ w3 {, IMODULE_AUTHOR("Tronlong");
0 {4 L3 H1 G9 C' J) Y, `: N+ p# RMODULE_LICENSE("GPL");
* o" j5 ]4 W ?* v; o
- f: W2 C$ x0 H8 \* t |
|