|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- F1 I5 ]' ~2 g. T" q5 K& k
#include <linux/init.h>
/ |8 m$ O6 E$ y5 w1 `4 `#include <linux/module.h>9 c/ Y) P/ m7 _3 x w( V: i( G
#include <linux/kernel.h>
6 f" Z, G0 M4 P/ Q#include <linux/types.h>
9 J1 |3 F, @( t. q2 @, l, s#include <linux/gpio.h>" w% k+ c) a; f+ q8 E3 a
#include <linux/leds.h>
) ?9 M# S9 e$ [. X" |#include <linux/platform_device.h>
% ?7 E2 v7 v$ a7 e
; c# J: d. q, {) M#include <asm/mach-types.h>
/ Z5 `( w3 r* s1 Q#include <asm/mach/arch.h>7 m2 w. E h' I) C g& h& h
#include <mach/da8xx.h>( W; w" h! p! Q! Q
#include <mach/mux.h>
{- ?3 L5 ]$ g7 [( m1 m! W7 P* n% {& m ^7 r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); @8 P. i- F# t; {; ?) X7 ]" d4 b2 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! z6 d3 \5 R, ?( x0 `# o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! s& c8 F- \( v+ a, o3 i! {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 n% a$ J6 D$ V4 A) a/ P% f# }0 B2 M# e, b& X. c3 a
/* assign the tl som board LED-GPIOs*/# w) ]2 W4 H1 H4 x( t; f5 I8 W6 r
static const short da850_evm_tl_user_led_pins[] = {
; k( g! N6 D( L! u" F" O" M /* These pins are definition at <mach/mux.h> file */
( v6 ~# P* M4 ~1 c( e1 X0 _" j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
M2 l1 ^0 \- E* G -1" n' s7 b$ N7 K; ?0 D8 {. p
};
) U' ?$ \& A2 q) {3 s% P2 {' \$ I: l9 I7 f5 c
static struct gpio_led da850_evm_tl_leds[] = { F' t; r+ r! s3 Z- c$ v1 m
{4 F* f7 [5 r7 T; c, o
.active_low = 0,
( a! e @& N* W3 f: p' h- V& E* V% l .gpio = DA850_USER_LED0,
) V9 w$ H0 v6 \) a9 z4 P, Y7 b .name = "user_led0",+ y: T, U: z, y' x4 R
.default_trigger = "default-on",$ j1 z: E T9 l
},
. Z( ^8 `. S- o. r( r, k7 v {# C/ B9 Q: K. K8 H/ w- z9 ~4 B
.active_low = 0,
# s+ s0 |; z* q* N' f- T0 ? .gpio = DA850_USER_LED1,
) Z9 e, R( Y7 Z3 S' t6 U .name = "user_led1",
$ {/ `+ `3 `* T6 D6 g/ ]" A" _ .default_trigger = "default-on",
1 @& r9 b8 h; h0 p* g },
& f5 F- m" E) C+ n0 R {
& I2 V8 a8 Z" Z/ Z' [! y. n5 n .active_low = 0,' R% ^" Z3 _' s d2 |: l, Q
.gpio = DA850_USER_LED2,7 Z4 O, x% v5 ^4 D3 T! a; Z9 z
.name = "user_led2",
5 Z# @( l& M D( } .default_trigger = "default-on",
* L- f, j/ n8 V- D0 g( v$ v },
: n, J) l0 t2 } {1 R$ U) G/ w; |6 j$ I, N
.active_low = 0, ?4 d! s `3 _: _. W0 c A
.gpio = DA850_USER_LED3,4 K8 o( Y8 E1 h
.name = "user_led3",$ S+ I, g6 x2 T3 Y( |9 ]7 [$ C$ A
.default_trigger = "default-on",
5 r: N/ D! n* \ },2 s, {& N/ L2 C6 ~0 l: D4 c
};( } E ` Y( i, Y
* N5 }: K$ ]8 v) x) M! S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 M4 v# _ Z% y* ]- Q7 {
.leds = da850_evm_tl_leds,, ?% g1 ~' B2 T7 t/ y& H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 ^- t4 A! g8 y" K' n8 l" B0 ?8 B}; N* c6 k( u5 e* I' z! y: ^
# ~. J3 L5 u$ t( z3 g9 ~% G
static void led_dev_release(struct device *dev)/ z. Y- I9 v' u- F9 ]: C; v
{1 r, ]. F9 P+ G, ^9 i; N( ~
};
! A; x8 x* e2 f. k, _# Z) I- X4 ^) U9 u% r9 C% D# b! n0 a+ b4 }
static struct platform_device da850_evm_tl_leds_device = {
! X8 `" R% B( z5 ^ .name = "leds-gpio",) u- t3 T6 m7 R0 G3 F$ C' X; a- `
.id = 1,
, h( f* R5 q: W6 M4 z9 D4 S4 ^ .dev = {
' z/ c1 S6 @, f& M' Y .platform_data = &da850_evm_tl_leds_pdata,
4 p1 q" e0 K' `# I: S; p/ R .release = led_dev_release,
1 t1 N, a1 \* M }) W3 \- E2 b) w
};' p$ m* U. X f8 d3 |% |
( r5 |* d2 m: X3 h. g7 X! a1 G# pstatic int __init led_platform_init(void). R9 q; b/ a6 d& Q$ r' y
{" \/ f! @2 g: J% L# A+ t( f
int ret;
9 _; @! S' W' U0 U' v9 [#if 0
6 N" x& f5 e( u, i" [/ {4 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 O7 \/ r& J4 Z+ h5 g4 Z4 {
if (ret)
U$ J7 J. B- k {; n% t. g: F% | pr_warning("da850_evm_tl_leds_init : User LED mux failed :") ^4 G/ z- ?9 D H
"%d\n", ret);
+ k4 g/ i2 A5 r$ E& x5 ^ k#endif
2 Q; J# D8 {/ Y# H0 ^ }4 }) S ret = platform_device_register(&da850_evm_tl_leds_device);
' j; A# W: M/ D7 H2 [+ g: a8 Z- w if (ret): Z( V# s- Q- \+ [- G5 y2 H
pr_warning("Could not register som GPIO expander LEDS");
: {0 E, Z4 O" B8 K else- j& m1 c5 l' X8 v1 w6 {
printk(KERN_INFO "LED register sucessful!\n");9 y7 ? n* U2 A0 W5 w
4 [8 G f+ j* A return ret;
8 m; O5 f$ O' ]0 g8 ]} v; Z8 {) T/ n5 x
% ]$ K# F5 H, h1 `static void __exit led_platform_exit(void)
' E% Z: g) h% T$ B4 T{2 Q M+ U2 r* v7 m- g0 @
platform_device_unregister(&da850_evm_tl_leds_device);9 X" g q. u) C' f- C9 u1 y
" q$ H$ \' I+ ]: [" C# n printk(KERN_INFO "LED unregister!\n");
+ x W$ _; p3 i- j, s# k1 _1 t- S: S}" M. X$ Y0 c" z5 q2 k* W! W
) T6 R0 ^9 h# v$ M
module_init(led_platform_init);
3 z {/ W+ P$ g6 l6 Bmodule_exit(led_platform_exit);9 @5 @0 ]1 L' R+ k/ W" o
# ^& [6 ]+ I" C4 n* Z3 M# NMODULE_DESCRIPTION("Led platform driver");
1 ~: ]5 h4 V2 C( v/ B* y8 hMODULE_AUTHOR("Tronlong");
% T6 G( U8 F/ @% T! H O/ m' wMODULE_LICENSE("GPL");+ v( J& |5 } F1 O' t
0 D0 d! I, S' p; v8 ~! b
|
|