|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* U# ^6 Z: q% P9 P P3 t' a1 w
#include <linux/init.h>! w/ O% g1 w1 [6 |/ f0 C
#include <linux/module.h>0 b' {$ X7 k9 ~. x8 K: b
#include <linux/kernel.h> V' d x* y$ ?5 w# O7 u7 u( f, z, J
#include <linux/types.h>1 c! Y: V% U$ M; x. x# e0 F
#include <linux/gpio.h>
: l% g/ Q) q9 [$ e3 O1 p; i#include <linux/leds.h>. Z* {/ \6 Y8 L/ M6 X
#include <linux/platform_device.h>6 l' N0 [( s. C4 q' I3 Q
% ^, z# P" d/ O3 O
#include <asm/mach-types.h>' d* F+ `9 a" y% D% N( ^
#include <asm/mach/arch.h>5 ^ ~) W9 m5 a; v8 D6 S$ X4 `
#include <mach/da8xx.h>2 }" m# l7 e- E: S s% O7 X2 w, J5 @
#include <mach/mux.h>7 M. r7 I/ l) I6 T V
/ C, f* N: M2 o# b1 [#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# ]+ j6 D, Q0 r% c, D" c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( M! S# s5 x- N, @. T: _4 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' p3 w! [, ]# u3 s7 y* W% R7 D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 p8 g6 W& E( F
; @# P# X$ o' g7 s9 g
/* assign the tl som board LED-GPIOs*/ Q# L0 L. F' E2 h) q& t
static const short da850_evm_tl_user_led_pins[] = {
2 R. B Y+ T4 p6 @$ b /* These pins are definition at <mach/mux.h> file */# C: ?: I& \ A5 W. h- T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ e+ Z' n4 \& G% c: O
-1% ], z# U/ V( P+ T
};
: h7 w8 @8 d. Z) N, }' u& H' n3 t" ]: m. D5 @ s
static struct gpio_led da850_evm_tl_leds[] = {( p* \2 H) ~2 q% U5 I8 d" t
{& ?( G' ~% `8 B
.active_low = 0,
3 k$ p5 W) R2 e: t/ M. o% Z3 O# X .gpio = DA850_USER_LED0,' `0 E& L( f6 m m1 N. I- f4 y
.name = "user_led0"," _; I# P# X; x9 @- D
.default_trigger = "default-on",
7 c4 ^/ g! k: R X$ p: U( X },, b C( `9 W3 s/ J# p3 {
{
, i: G: I. ]0 V$ h) X' ?# w) E .active_low = 0,1 P e: P; i; M2 I
.gpio = DA850_USER_LED1,
0 A' K* p2 D7 c. w+ l9 m .name = "user_led1",# K D! i' O5 f3 L
.default_trigger = "default-on",
5 u1 J) i* u% k },
# z1 C" L8 e% f3 `: \" ? T3 ~4 Q% j {
- l9 J' w9 L$ {) H; ^- c9 e# Y .active_low = 0,
% n8 r( M6 l i+ M* t .gpio = DA850_USER_LED2,8 [& `" ~5 K. j/ A K
.name = "user_led2",
8 m0 M+ g7 g, w% q2 ^& X .default_trigger = "default-on",) S% t2 B, M# J6 l
},% o& k" O- w+ o* S% o
{8 E H4 L" l. W* x+ _2 D
.active_low = 0,
S* `" G% T. A0 Z+ @ .gpio = DA850_USER_LED3,
% q2 x$ \: a' f: D .name = "user_led3",
/ }7 H8 {7 c3 [* \, z7 i- w, n0 v) r .default_trigger = "default-on",
7 r; Z( y$ i d2 ]4 O },1 V: H9 ]* N3 {1 J7 G2 j' s5 i/ x
};/ A2 O$ q, T3 A: B
# L6 ~; a( N1 h$ e' l& O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 y$ v) L. @& g0 | p .leds = da850_evm_tl_leds,$ E8 u" ^ Q6 n# C6 G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," B. m2 M9 I5 s6 W9 @# V# k& s9 c+ _
};. }3 H% N: m! C- M7 U
1 g7 R6 L* K) |. [, r* Estatic void led_dev_release(struct device *dev)
* i# k, a7 _3 F. f{* Q# [; Z; H6 c+ W& o
};
7 d4 P, ~1 O! N. S& g9 a. z0 {# l% J7 |7 H+ {& g) B
static struct platform_device da850_evm_tl_leds_device = {
. c: w" B6 O' i+ A .name = "leds-gpio",+ j; A9 [/ [) H& J1 J5 u+ h
.id = 1,: \8 U3 @; D, y+ r9 r
.dev = {
( Y' |: e+ M; z% m* a .platform_data = &da850_evm_tl_leds_pdata,
" ]: |- G- g- C1 J: M* V8 M- } .release = led_dev_release,+ S Z+ I, U7 l. ~5 e( ~5 p6 j
}( e; ]6 E% p m
};
' k- m% t' V7 o# I8 G
% p" ?2 Y6 Q" `5 J+ Rstatic int __init led_platform_init(void)
. F8 m# Y2 e% R{; H& D# N1 t5 s# \0 `( o
int ret;
, Z G1 A. T! h4 ~1 j1 v6 B#if 01 b: e+ y8 r" \- r9 [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 Q3 ~: t0 {# } if (ret)6 q& P$ R+ m* g6 ^: }- ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* J0 l2 j; R% f& {# h
"%d\n", ret);
; P' i5 J& q# j) U- N$ m; O. f#endif% p& P) S1 _+ \' X4 H7 Y
ret = platform_device_register(&da850_evm_tl_leds_device);
" F( ]. S+ m3 _3 h if (ret)
/ ]1 U, ]1 C. j$ i4 `( j/ z pr_warning("Could not register som GPIO expander LEDS");
. v. I+ C1 {/ p8 S( T0 q: _ else% N: |5 t! Q+ ]& n5 Y' a
printk(KERN_INFO "LED register sucessful!\n");
& H* t& a& m2 ~, f. K) H3 L9 b: p5 X. T. _1 n1 a6 k) W) t/ ?
return ret;/ g5 O; c/ F% ^7 K/ r# a
}1 W5 Y7 ~, j& e2 w8 `
" Z7 ?2 r* ~/ \static void __exit led_platform_exit(void)7 ~- j2 O0 |9 ?+ }5 G) V! U
{
# ^/ g$ ^ B6 B) P# b platform_device_unregister(&da850_evm_tl_leds_device);" c/ x+ f8 A# e
3 h f7 Y( g9 @$ \& d" C$ b printk(KERN_INFO "LED unregister!\n");
: X$ v! L4 `) v. @7 l}
: n1 t$ c* o) `! y5 H# v5 \+ X. A1 P1 y- a, v
module_init(led_platform_init);! T) A) N/ e8 i3 Y" W
module_exit(led_platform_exit);/ g0 }& t: q* Y) e' \: l3 a6 E) N
$ \% @4 V/ x) y) n, ~
MODULE_DESCRIPTION("Led platform driver");
; a) G+ B$ o% ]/ W" dMODULE_AUTHOR("Tronlong");
1 R0 c' N g$ l, R9 K1 pMODULE_LICENSE("GPL");) g1 ~9 Q/ m. x. L& B7 L
; n) B- k! W- v |
|