|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: D7 M& D/ J& h) ~" X; D
#include <linux/init.h>
6 _2 _7 w3 @& L% R, \& e#include <linux/module.h>
; I# x& [( w6 |0 C#include <linux/kernel.h>
$ A5 x4 t; `" A t#include <linux/types.h>
# W M, N/ v$ l: ~$ m#include <linux/gpio.h>
- O. K) N5 G- j- f* `( ~#include <linux/leds.h>8 x4 ]7 n/ U1 O/ D( X% m E8 m
#include <linux/platform_device.h>
8 P: I) ?/ P) P/ ^2 Q
, n& B& n7 q* E& u8 z: ? n- H G: [# s#include <asm/mach-types.h>6 U$ E% |# C2 }( f9 \0 |( }
#include <asm/mach/arch.h>( ~5 t3 R( U. Y
#include <mach/da8xx.h>
/ p. f% X, x3 E4 Z#include <mach/mux.h>
8 h1 [" C4 _: v
5 S+ R6 U9 Z, P/ E8 e0 S# h9 B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% N9 l( z- k0 ?5 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), H, R/ m/ I% _. {7 j# z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; x8 ^# ~; t& V$ }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, N$ t; ?9 z3 R+ Z, O; m3 Y4 F+ M, M( d# D+ B
/* assign the tl som board LED-GPIOs*/
6 P. _# I8 t* m" X. {! Cstatic const short da850_evm_tl_user_led_pins[] = {' D+ H' K3 s- [$ D& n. X! t6 V0 Q
/* These pins are definition at <mach/mux.h> file */
9 [! B9 V9 H0 z0 g( Q* R. L: C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 }& Y: Q f, N* [0 k* ]# X
-1
7 [2 x, a: D% g2 v- l9 x& D( ]0 u};
$ P" U0 V8 B6 W/ h" ~
! x: T& a; }; {static struct gpio_led da850_evm_tl_leds[] = {
j% b" N$ J3 | {. {* t9 \& G* E' U( U' y9 Y
.active_low = 0,) y% d; _$ _4 E) U! |
.gpio = DA850_USER_LED0,
5 a3 ] o- O; h, |9 \/ T" k .name = "user_led0",; u( f' g9 Y( I9 y2 W
.default_trigger = "default-on",
1 U; C$ Z, o3 o0 y },+ y% T2 D$ h" h; O/ y) i8 |
{
1 _# C/ C. v9 D( I .active_low = 0,/ x4 d" o; ~3 Q
.gpio = DA850_USER_LED1,' l0 \1 J& W% q! q$ B! f3 c+ y
.name = "user_led1",
# C8 i' Y% k. G: [5 g+ Z .default_trigger = "default-on",
) W& `! j! l6 _2 |" Z# \6 t },
, `0 \2 { ` Y4 U% P. @ {
' K0 j" ?; w! H1 U .active_low = 0,/ E) z- R. S& C7 z* F4 D4 G8 Q1 H7 V
.gpio = DA850_USER_LED2,% u" C/ r; Z/ [5 E* O
.name = "user_led2",9 _8 @3 C1 E5 Z+ H, s q, E# S
.default_trigger = "default-on",$ Z- [7 M' U6 l
},/ \( }% j0 d0 }, F) a
{
% t6 @* o$ Q7 ^5 D9 B( n( K+ M1 { .active_low = 0,
9 ~! j9 B% S1 ~1 F4 G .gpio = DA850_USER_LED3,
% s! @. X9 ]2 u1 y |& X( ? .name = "user_led3",$ k5 d5 ?2 U) L0 \3 T$ s: R& p0 j
.default_trigger = "default-on",
" f. S1 E7 o8 x4 K& Z2 o6 @ g" k }, @4 k/ B5 L( H6 q% t
};
6 l6 m( a% N2 w& n) v' D- J) ?/ s( T4 T8 g! B- \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. q3 f# p1 V! F ~' M. f% S
.leds = da850_evm_tl_leds,3 O0 ~2 ]& f* c6 G0 y; _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 x3 f6 B* G1 x3 Q, R6 g
};; s2 H* e" [/ l H
; D. T- R6 f6 P( D, e' p3 z
static void led_dev_release(struct device *dev)
& j' w1 y" p$ v2 @5 p{
8 g. A* G2 j v) f/ i};1 x% R( Q! T% X2 ?; p
& |4 r( w p4 w8 y' s) fstatic struct platform_device da850_evm_tl_leds_device = {
1 H$ @) n- P( p4 J .name = "leds-gpio",! _ m( C" a: B7 h& I7 ^
.id = 1,
: c! L1 V' t! v .dev = {* D" x, Z$ N3 {$ B
.platform_data = &da850_evm_tl_leds_pdata,
/ y/ E7 [6 y8 T, F5 W .release = led_dev_release,4 B) L0 I7 h# M* w1 P1 l1 f
}2 Y/ Z% t: x, q7 u( |/ s2 S W- {( ?
};( {* W8 P4 a6 L( f7 B1 @( D
, n+ i7 I7 R+ z! J
static int __init led_platform_init(void)
# G5 M: }$ \$ r' m- t1 F{$ U6 c+ I1 `2 `0 O# _) Q+ F& f
int ret;5 L4 x1 U$ M% [ Y
#if 0
; ]6 \- Y- V+ N$ s+ B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 f1 M& A" I5 S: g8 J
if (ret)
8 k8 f3 U+ V& Y- N$ u pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 d# q9 z3 c, P+ @4 g1 P "%d\n", ret);
+ T" q) D/ V5 c0 y5 `- s#endif
5 ?+ p% T- e' q a+ h9 e5 d ret = platform_device_register(&da850_evm_tl_leds_device);! \! V% H7 p6 P8 V3 X. W1 u1 @1 N, ?8 N
if (ret)
* G4 B9 O" I( b8 k7 Y0 w pr_warning("Could not register som GPIO expander LEDS");
6 o, S. a4 ?7 x# z1 ] else
) V' t; N2 y. a. B3 e: m+ {4 U printk(KERN_INFO "LED register sucessful!\n");
: l( K, s) y2 | D; K9 h
) x8 ?$ W. s# E+ p6 T# e return ret;
6 s T! F2 y- H}' @( g e; w( _8 y( Y6 T
; D6 |- n6 o) x$ C# estatic void __exit led_platform_exit(void). r* {- [% l4 Q/ i% ?5 i, r+ J
{
1 \ N4 N2 e4 C+ C* _/ z2 C# Y platform_device_unregister(&da850_evm_tl_leds_device);+ a( E. r; Q0 |
- z9 c) @5 P4 ~+ V: `5 x/ w+ M* A, S printk(KERN_INFO "LED unregister!\n");/ y. K' [5 d! m; j1 p3 B: n
}
: e! v, c; P* y& w( T3 R, `
# D! ?6 `6 |' Q2 y2 Rmodule_init(led_platform_init);
, J1 S' T% v8 ]' Z6 C0 l# z, qmodule_exit(led_platform_exit);
" A( L; p |. D- M! O/ F/ O& b3 d x0 Z+ ~! J
MODULE_DESCRIPTION("Led platform driver");/ C, `( `0 K- i
MODULE_AUTHOR("Tronlong");
/ y( m. @0 F5 C: F1 l1 n+ x; nMODULE_LICENSE("GPL");5 C& b3 Z& R' v. _1 F' y! H
5 l! a' A, e( j6 F. F: `% B |
|