|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 h+ y( p/ ?& \9 r ^; O#include <linux/init.h>, `. L& `, i, {/ y1 M. u
#include <linux/module.h>% H `4 X$ j! w: F" `8 n
#include <linux/kernel.h>" X6 c' v8 u: m( b
#include <linux/types.h>0 p1 V% _0 s' Y$ h' x$ U3 K
#include <linux/gpio.h>( B5 l" `0 {& X" o* t: q
#include <linux/leds.h># c* C2 d& V+ i' a
#include <linux/platform_device.h>3 V L8 O% Q* K1 x: J* c
$ C! o& a$ V' \+ A- i
#include <asm/mach-types.h>- n7 e: Z* t- k% m; W9 i, i$ Z
#include <asm/mach/arch.h>
4 U ? v3 S! b6 C6 {#include <mach/da8xx.h>
& q, f; g, T) ~#include <mach/mux.h>) w- j3 {& {9 P3 e) a
( o/ C, E. a7 m5 T1 ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ H6 i( ]7 {+ [$ h+ n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 I+ U" O+ n4 h3 w z7 h5 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ o- Q9 H* g" B8 N$ B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ T& A( q; O) W+ a% T9 f! i
' u# {( z! \3 {7 X/* assign the tl som board LED-GPIOs*/
9 W' M/ }& j7 h: D% S( \static const short da850_evm_tl_user_led_pins[] = {9 }$ |3 h9 d% I% |. t+ V- j
/* These pins are definition at <mach/mux.h> file */
v* s3 h; B. [$ t( } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 z; @1 `6 U0 z9 l -19 b- g+ f# s, \! y5 d/ m
};" i, r& S6 W2 ^) `
/ W+ G0 A7 F$ I: o# K5 t9 vstatic struct gpio_led da850_evm_tl_leds[] = {
9 N. L+ l# V6 S2 V {7 e, B) {% G1 x f" ^) A
.active_low = 0,; x% |5 }9 C/ N$ \8 f+ j3 P+ P
.gpio = DA850_USER_LED0,
% a L( B7 R9 {2 ~: _ .name = "user_led0",
- i( e% ?1 L9 l$ \ .default_trigger = "default-on",
* g" W1 d0 _# m( R },
% n; D$ x1 @ G {
6 }- l! L4 K$ S7 D .active_low = 0,
+ j: d$ N# q' w8 B% V% [. ^ .gpio = DA850_USER_LED1,
1 y7 [6 n9 M* m6 R3 E .name = "user_led1",
/ L! y9 f5 v Q" y" \5 H .default_trigger = "default-on", s* p/ a. Z2 s6 O
},7 k/ f' r4 U4 e& h
{: }* f. f+ J, k0 z3 ]' m
.active_low = 0,
: a! f; y2 B- P! z0 n! Y .gpio = DA850_USER_LED2,6 F0 S2 s% G3 H4 P+ h
.name = "user_led2",+ ?: m$ Y5 g7 |, ^( ]6 U$ x0 E4 f& B
.default_trigger = "default-on",
% U: G4 g, q, W2 {7 K& T },
7 ?; G" v6 o9 n {
$ Q1 Z: z: _* ^ .active_low = 0,3 @5 K8 H* c3 H0 a/ m2 G; T. w- Y8 u5 v
.gpio = DA850_USER_LED3,
; M7 Z; {0 L: ?! s v9 s' { .name = "user_led3",
- N+ o) j" v& h& ~3 d9 f5 I( R% g+ } .default_trigger = "default-on",
! r1 X( K2 K# F8 z- c+ E },/ B( `: c- N5 g: K8 w# a/ ? U: f: C& a/ q
};
9 E+ ]! X9 Y0 J* x% H$ z
. Z7 q' D' Z; ~7 w [( X' x8 \8 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 @; F) U. ^! c; W# m0 M3 K3 _
.leds = da850_evm_tl_leds,
* G o5 S2 |' @+ p5 c .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& f% j8 ]9 a ?) A% {};0 u, t; G" i' q7 W, ~# c
/ t1 ?5 y2 t- N, Q7 @
static void led_dev_release(struct device *dev)
& }* J9 ~) c5 q" N& R{
. t( o4 A" p& c};
# @* E) B& H$ o+ e- @4 q* S! ^2 H/ E' J& L0 E! F. L
static struct platform_device da850_evm_tl_leds_device = {/ m' b) k8 x1 [/ Q3 A( N* I9 D
.name = "leds-gpio",* s( N/ X: A. a( K" T3 W; v6 @
.id = 1,
2 {8 X( p: `' Y$ } .dev = { a) b. i" {2 _) L
.platform_data = &da850_evm_tl_leds_pdata,
. m! K6 ]. _( |4 V. g- G .release = led_dev_release,
Z3 k6 a/ x1 A! k+ P7 F& W5 | }3 E$ G7 ~- P6 K3 L1 P, e
};4 }8 n/ P2 r$ W+ E- X; x
; ]8 n. W/ y% Bstatic int __init led_platform_init(void)& ^- c+ g& y5 M
{
$ V5 D- m( \2 u/ O2 y int ret;8 q; t" i" ]6 D: A
#if 0
( c9 t5 X7 A% d6 |0 `2 g& m- K+ X5 B" P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 I7 {* E i- ]8 ]2 W
if (ret)6 E. N1 Y+ I9 B% P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- n& k( Q% c5 q" u' n, K4 r( T5 f
"%d\n", ret);
[7 ~) R9 j! r- ?#endif
5 [4 ]2 w9 Z( C ret = platform_device_register(&da850_evm_tl_leds_device);! L. d, ]& W8 x7 `
if (ret)$ S* A E1 M. f0 O
pr_warning("Could not register som GPIO expander LEDS");
' \8 h$ j' @1 P1 k* n0 V7 ~ else' D6 \8 h. \9 s% g& f0 M" j
printk(KERN_INFO "LED register sucessful!\n");2 G9 n# v4 _6 V( r. c
$ A1 \! _- e0 u& F t return ret;3 p8 b, [6 w: a+ s# Y. d
}
! C5 H) V, x" m4 t& r9 U( f9 \, R. }# E" m/ [5 t N {
static void __exit led_platform_exit(void)( M1 [" I5 X: i, a2 ~2 M
{
' J# | k: k, P Z1 Z, l) d' o0 R platform_device_unregister(&da850_evm_tl_leds_device);
" `! c$ n% I9 o, {. P. F5 g) B2 T' S
printk(KERN_INFO "LED unregister!\n");7 ~ ]4 D& ~: a
}
9 T _3 @! u. o5 ?" m* R+ t' L7 G! C* ], O$ f
module_init(led_platform_init);( P+ O1 x. g. o- n) n6 d5 t
module_exit(led_platform_exit);4 N! ?4 M; n( J# B' J
; R& Q& Z, j1 \4 e# W
MODULE_DESCRIPTION("Led platform driver");8 Y5 l9 U) \- j8 y8 h3 y" z
MODULE_AUTHOR("Tronlong");
7 Q5 P1 X$ m2 l: k# {9 xMODULE_LICENSE("GPL");
1 S/ i- I; C, U' T9 r0 a4 m0 N( I+ x: L& s
|
|