|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 j$ b* O+ G9 V- i P: E$ n$ v#include <linux/init.h>% W Z4 k! d/ H$ T/ p& R
#include <linux/module.h>
1 w) d |( H+ D: j#include <linux/kernel.h>
8 b- x" \5 y! K0 I, o5 W#include <linux/types.h>; z1 p! S, h8 w1 S4 c0 Y$ r
#include <linux/gpio.h>
% e% @6 I6 ^6 H" ?#include <linux/leds.h>' v k5 f5 w5 i$ c/ M' v8 d3 v
#include <linux/platform_device.h>8 S: q; Y8 T% t1 R( W$ K
- E% H0 A/ D# N9 s; {6 H5 P
#include <asm/mach-types.h>
" c, m: {/ f! b2 {5 R) W#include <asm/mach/arch.h>
$ h7 Q4 v F& Y#include <mach/da8xx.h>
?) H4 u# F' M5 I6 G) y6 r#include <mach/mux.h>
2 e, a" V4 |9 S& F8 x6 i8 P0 d7 M: j: _
( N6 U7 z/ b# U* d! r# D: y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) Z: z: I) u) i2 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); y" n1 ?8 N' D1 L# Z7 Y7 `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 N6 n6 u7 C3 i7 R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ S8 }2 v6 G0 u" Z* I# N% h5 ^
2 A5 `4 P+ k z/* assign the tl som board LED-GPIOs*/+ {# P/ V; l, r8 C3 s; _- l
static const short da850_evm_tl_user_led_pins[] = {! a8 B- y' {+ C+ q4 G* v6 _0 B
/* These pins are definition at <mach/mux.h> file */) g* ]1 k* w5 v. Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ d; p" V t/ c: e -16 r" C/ f% W6 G0 ?( u; ^7 I9 z) O
};# _: I+ `8 P4 e
4 {5 z( I2 X" R+ Z) L- `. ]
static struct gpio_led da850_evm_tl_leds[] = {
0 I* D) K6 r9 V- P0 L( q8 T {
0 M2 G3 E' u5 n f% ? .active_low = 0,. |& @) r* m: C6 Y& V
.gpio = DA850_USER_LED0,
& t6 h1 I% D- V3 A/ Y8 k Y0 \" |: U .name = "user_led0",6 _+ E* ?, s! {" T" f
.default_trigger = "default-on",5 m0 E3 g6 y/ S, n2 T4 A. b
},; e' b& W% m7 s+ X( b( d9 O; [7 ]. ^
{, w# C: M1 Z; G0 _
.active_low = 0,
% Z& G; x! f5 X; L/ j .gpio = DA850_USER_LED1,
4 J6 K0 r: s i7 @, l .name = "user_led1",2 `( u1 w. ^3 z+ t/ Z1 J7 g
.default_trigger = "default-on",
$ o. w ]8 ]1 ^8 S% `/ Q0 A },
" C% y$ x' O, h) r' x+ x' U% Y {4 j4 O0 k' L) f6 L% t+ o/ X) e! g
.active_low = 0,- X( T7 `: G+ B: C4 f
.gpio = DA850_USER_LED2,
) G: q7 S- l9 X# J .name = "user_led2",- M+ m/ F( ]6 g3 c8 b+ r
.default_trigger = "default-on",3 G/ z) y5 j; \2 u: h6 g
},$ o" }1 w9 O0 ~9 e
{
7 o0 m0 t, x. H" e .active_low = 0,
2 D4 x4 B; c& u8 P; s .gpio = DA850_USER_LED3,
2 W2 j6 N1 R( q2 [$ @: n8 u3 D .name = "user_led3",
+ y+ g" ^/ U3 [. l, ~ .default_trigger = "default-on",
+ X4 e. n" V3 c },
) v& ]( g7 }! z" a: `' I};( e. T# z' Q$ j# d0 ^/ Q
: P) z3 Q2 [( [, e x% Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
L3 G' V W0 ]/ B .leds = da850_evm_tl_leds,6 [: {* z: _. L* {6 K$ U; x2 P. ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" T% m) ]# O' ?6 F, ?};
) `5 Q9 n) o2 e* h P: B
3 n5 B! i( x q& r) ^- |- B# {static void led_dev_release(struct device *dev)' }' {8 H# Q1 R, y/ C S
{
( W! B' m% G8 E3 o};. R, A h* z0 A9 p3 Q
; T5 A% J$ v5 E& q f
static struct platform_device da850_evm_tl_leds_device = {
, x6 @" Q5 L% u" o4 ^ .name = "leds-gpio",
. c- ]. d6 q: D# T3 m6 t4 `' d4 J .id = 1,
$ @) L5 t! o5 s1 A# T! U$ G5 I .dev = {$ l9 K q9 Q& b3 a9 O6 L: o2 U6 s
.platform_data = &da850_evm_tl_leds_pdata,
7 o# E- g1 L* l# R% e- h .release = led_dev_release,
' j5 Q, D0 C4 \( w$ R }
8 f! ~+ v; F" v( K4 v};
G3 E+ @# p% s3 @) n. S J( P+ h/ j2 z, B; }
static int __init led_platform_init(void)
) W' G: V2 X' c1 P8 a, O{
9 }8 ~/ r: C: c9 v( r8 s int ret;% H6 a. c3 v; f2 r& z+ V
#if 06 a& ^4 p( r& I% R4 p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( J5 S# a" j1 d* E1 S9 L {6 I if (ret). |) ? _9 u. o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
x: A; Y9 _' c "%d\n", ret);! l. g" ^5 e5 Y, j# W# G3 ~" E
#endif; U# n8 u: B7 W q2 Z2 L: a
ret = platform_device_register(&da850_evm_tl_leds_device);
( V$ B4 e$ o p' I if (ret)
7 j/ B* d6 V# r2 w9 L3 O pr_warning("Could not register som GPIO expander LEDS");) r0 x2 u' L* C/ g+ A% t9 ]
else7 f) E4 C8 P' h4 p& f% \4 w' E" E/ d
printk(KERN_INFO "LED register sucessful!\n");
L- v4 x& V& [6 f" @+ ^+ D* H# J& H) h L5 D
return ret;" t/ I t/ s1 J Y9 o3 r
}8 a1 X, {6 E1 y v* C" C) D: [
" ]& D9 M) D4 K. ^8 S% x' nstatic void __exit led_platform_exit(void)
" G& T- S0 v5 u# R! X8 a; }; ]{
3 q! q b6 k: @9 i, Y# d/ O platform_device_unregister(&da850_evm_tl_leds_device);, E C8 ^% n# v; g7 y
! ?& l; V) ?: m. b$ W3 x
printk(KERN_INFO "LED unregister!\n");
8 c! A% q. I4 X6 K( V, x}
* s# S# {% c0 h3 g* }9 `2 R/ M( [9 q, v) D! {# y3 T9 y( k
module_init(led_platform_init);3 y6 \, k: d* u3 p0 [8 C: ~
module_exit(led_platform_exit);
! I% c, X1 p) V7 M% a
7 ^* [: }5 @1 T/ `3 EMODULE_DESCRIPTION("Led platform driver");, Z [1 ]$ O9 X/ ]0 w
MODULE_AUTHOR("Tronlong");
3 G* {' U: M( _1 GMODULE_LICENSE("GPL");0 I9 G' |9 E+ J$ @
) t u# \9 }$ o0 j6 R2 }
|
|