|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 e$ a) a' C3 ^' [4 V0 \ _
#include <linux/init.h>
3 n- q1 U1 n6 { P#include <linux/module.h>, T3 a, A$ w( ], L9 |* x
#include <linux/kernel.h>
* |: g) ~7 u# ]# T$ r0 e/ S#include <linux/types.h>: x" O# L L* K' H
#include <linux/gpio.h>9 g$ G$ d0 ?" C: \
#include <linux/leds.h>6 J) I: f7 W: e' h; u- W
#include <linux/platform_device.h>
( _8 F6 V4 n$ {% V V* K1 z# A" L( u' a& a* u* w8 }! l
#include <asm/mach-types.h>
& r G3 d, F ]: d8 }#include <asm/mach/arch.h>0 C$ X0 R/ z8 @5 z" X( C& v, h+ t
#include <mach/da8xx.h>
6 I1 i& W# o+ U% {#include <mach/mux.h>3 ^+ p+ d# K" K9 E+ s
! r+ T& d" y( ]( J1 S: o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& x a. W6 A* _! g& ^ W+ n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 c( t: T& c, e4 V7 F+ v' [) V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, e1 E, E' t* N* M! U" I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; s. n0 F1 O9 L
' c! ?+ a2 w- D6 g! E; }/* assign the tl som board LED-GPIOs*/9 I* {+ S* e M2 Y$ x6 a
static const short da850_evm_tl_user_led_pins[] = {
4 L& t, q) y' E1 W/ Z: Z /* These pins are definition at <mach/mux.h> file */
1 k+ G3 t+ c; A2 q+ [) J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# S9 Y9 i9 O1 b( F& U( C" y& K -1
8 ^1 z; ^# C% l% I' T3 u};
# q- j' }! `5 a \6 K8 C% f. S6 G3 X
0 J6 o: i9 U3 Z. U6 z. Q Ystatic struct gpio_led da850_evm_tl_leds[] = {
' B. ?4 ?1 R9 q) E" }. d l {& B( p8 M; q. ? e( Z$ b
.active_low = 0,) j0 ^) U) _' p$ ?; Z& O
.gpio = DA850_USER_LED0,# c8 J7 H' O* ~0 Y
.name = "user_led0", f5 V' c) e" j. a9 |8 i/ K: I2 d, n
.default_trigger = "default-on",
a* b1 D. A& v/ D* F$ W) u: @ },
) a# E" P5 t) Z8 r7 {, b7 J+ \8 \ {" H' O3 G; I% `8 C
.active_low = 0,- [6 Z f% O7 J# `
.gpio = DA850_USER_LED1,
# L) W' D0 R7 j; n+ J7 q% O0 t9 J0 B .name = "user_led1",6 }3 {) D, Y: _+ i* i8 s- {8 D$ p z
.default_trigger = "default-on",
( D! m4 n! t, c) z! Q- E7 T },
- p, p: d8 g0 ?; \+ f1 c {, p4 r* v; y7 O
.active_low = 0,
1 g! V2 m: e" ^9 Q; ^ .gpio = DA850_USER_LED2,9 w% \+ d) A& {5 z) h: I
.name = "user_led2",
* v/ J/ L: y Q' N Z .default_trigger = "default-on",. {: a3 B2 M6 I6 r- I* o' |4 Z0 m+ r; S
},
0 h" V8 F3 E" e) m$ S5 F {
1 I! ~, |- s$ S& [ .active_low = 0,
$ H% ]' y9 w2 _5 S$ \, k .gpio = DA850_USER_LED3," a5 T3 Z( T" J8 f* U' C* k% j
.name = "user_led3",
% e4 J+ d! R# W9 t v$ U! ^ .default_trigger = "default-on",
6 Q( V# f- z( F: C' P0 d4 r },
" t& d( f9 g; C+ V; I; J};
4 G+ h+ d$ ^& Y+ x) @3 i/ r" U$ g4 ]. F/ ~! I5 d3 j) d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ ]/ J9 {: e A; h/ N .leds = da850_evm_tl_leds,
4 l/ G+ |; B& I: p H! Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# y6 P" `+ k$ I! @; w8 w! Q! G};
2 g+ i2 _0 O; y7 P! \5 c, F( E# w$ `1 t2 T8 P; G o# q9 ?( I
static void led_dev_release(struct device *dev)/ i e1 O5 k6 r8 g( Y: C' {
{2 M5 p7 J( k% g) L6 }# K' i: i
};3 Y1 Y# D6 ?7 w1 \" ^. l
5 j7 p9 j% e- e# L+ Istatic struct platform_device da850_evm_tl_leds_device = {! {7 p2 i3 K! Q
.name = "leds-gpio",
1 l+ X8 m# ~( g; e. ^! Y7 l .id = 1,) w2 F! ^% T. E2 D! S/ }/ J- |
.dev = {
; |4 u% i% x' q9 F/ _" d .platform_data = &da850_evm_tl_leds_pdata,; V2 |: ]: ?- Z' l$ n
.release = led_dev_release,
' z' _5 H5 Y; h, e( Y& k. E }
2 a; Z" Z+ k% }) I};
+ F( H: G& R4 d" I0 `9 c% ?+ p) _# j; x( B5 T. V
static int __init led_platform_init(void) F. ? `$ g5 e+ H# E- s. ?
{
6 Z5 T5 L. P& W( h* d/ ] int ret;
! k1 ^2 {8 @4 A) _+ Z7 C#if 00 [4 E; t0 J- {$ H2 ?% A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) y j5 h7 ?1 v# Q9 L
if (ret)2 w/ }5 a: a: ^, y+ e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- R1 t3 x( [0 X, N8 O8 e2 p
"%d\n", ret);/ x& C, G# v5 z8 i! k; J4 V3 s2 Z4 D
#endif6 r5 E9 r* Z% L
ret = platform_device_register(&da850_evm_tl_leds_device);# |8 k$ _5 I- ?7 D( q
if (ret)- t6 r/ E$ A) i
pr_warning("Could not register som GPIO expander LEDS");; O( S% y, p' {7 w r
else
, A x+ o; n; H$ f printk(KERN_INFO "LED register sucessful!\n");# D4 u8 t5 U8 b- t- k2 }
" r) T8 h* i4 Q9 ~! z! s/ x( B' o
return ret;
2 l- [, m( J& {9 `}7 Z% `" U3 C8 g/ a1 ?1 p& J9 X
8 U2 f) v0 R- c) z! v
static void __exit led_platform_exit(void)6 X M( P! |# M/ w
{4 `' T) u; a/ |& w2 l0 v6 a
platform_device_unregister(&da850_evm_tl_leds_device);6 X3 T5 x9 H! @6 q. o/ p
* `- y# z; p2 \ printk(KERN_INFO "LED unregister!\n");# L* S5 w( t0 h6 Y' g
}
u0 Z- e% [! y! c Y% T+ J. ^. s7 z V4 F
module_init(led_platform_init);6 v4 K7 B# [/ N& {1 I3 F1 b; {
module_exit(led_platform_exit);
- W' `6 P7 G0 K( s: _
! N! J( @) z7 }3 S5 q3 qMODULE_DESCRIPTION("Led platform driver");! V- P, T) l( h6 O- O$ n; K, h y' R
MODULE_AUTHOR("Tronlong");
+ Y% w8 D$ J' K) i) A" N2 H7 x4 jMODULE_LICENSE("GPL");" P* T* Q( q7 I' e- o$ P
& H- \# n% e0 f. s, F |
|