|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ `( o$ ~. h8 D# ?! Y#include <linux/init.h>
/ w6 m `2 k* ?% L& @#include <linux/module.h>
9 M: F1 c- A ^3 z: p v4 }$ ^#include <linux/kernel.h>+ {* ~8 r3 b$ G6 X1 {
#include <linux/types.h>
. w% ^& s% e! `! B; J#include <linux/gpio.h>! f. q5 Z! ^! C
#include <linux/leds.h>" b: o0 a* W% r' U8 n! a
#include <linux/platform_device.h>
, k7 I5 E' d! ~9 u. A, K/ k; G7 d% i1 d) K' x/ h4 n0 j" E5 b
#include <asm/mach-types.h>5 r' c i0 w7 [( D+ f ?' o
#include <asm/mach/arch.h>% l( Q/ H( s7 z+ A# m* ]
#include <mach/da8xx.h>: _/ l8 T/ k) W& \( I! H
#include <mach/mux.h>; b/ V }! U9 A2 m
. v: H) [/ R5 f) B7 ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 Q6 e! P, J1 H3 C( K2 J6 n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" l! v F! b9 I% L9 q- _8 D9 v, @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ o( W7 l1 b8 C$ j: x# `" ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- E+ Z+ c8 g& X2 Q
0 R- d7 n3 \/ [/* assign the tl som board LED-GPIOs*/
; W* e7 u1 U& w+ F+ j+ E& z1 h, v. kstatic const short da850_evm_tl_user_led_pins[] = {
2 D( A* U- N" X) W+ m5 i( D /* These pins are definition at <mach/mux.h> file */
0 o8 [( ]4 o a* L; E$ V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
F0 k S$ c- r$ t4 C -1
) j2 x z. ~/ l}; L' C A' o; k1 X( b
9 d, E( n5 X7 Qstatic struct gpio_led da850_evm_tl_leds[] = {
* e. Q( B( d4 |# ] {
U9 G. G% ~+ {- ] .active_low = 0,
9 q" ^7 v6 H$ S7 \4 K0 X3 t .gpio = DA850_USER_LED0,
! }6 J" H( T; X7 t& B& w$ J .name = "user_led0"," U5 ?% z& S4 R7 E
.default_trigger = "default-on",
* g; k6 q, n' f" w% r% ?8 e },3 _2 f! m$ H; F( l
{! r6 R) T4 }- U. p& h$ F% l2 h
.active_low = 0,9 ?; q/ L9 c. i
.gpio = DA850_USER_LED1,) Z7 }4 g `1 \$ T0 ~! q5 x
.name = "user_led1",
& K. ], i# n2 l$ Q3 @' F$ y .default_trigger = "default-on",' c# ~/ ~& p) V0 @
},8 }. h/ ?. b k! c+ e9 J: x: d
{3 T+ w/ Y3 [9 s9 t8 p
.active_low = 0,0 ^0 a+ e: i5 L" g
.gpio = DA850_USER_LED2,: ^1 J) i2 Y4 U! [
.name = "user_led2",
9 Z% l- T+ t t/ m0 k7 S4 k- R% R .default_trigger = "default-on",7 O; s5 C6 \4 _( P. F/ ^
},
], f5 L/ I% _# t& ^ {
$ N( s% [' v$ P$ c& u- Y1 Q .active_low = 0,
0 ] {- r! [+ ]1 m; I/ \ C5 t0 x .gpio = DA850_USER_LED3,5 d6 m4 K4 o R# s. [/ n- x
.name = "user_led3",, }3 V6 J" f# u! g" g
.default_trigger = "default-on",9 @& i6 Y) ]. T7 S/ H6 ~9 W/ R
},0 v; M7 Q' d8 A
};
7 y" Y" t8 Q5 \& F' F5 E7 V E w! l& \" ^# z6 s3 |& y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# d( n7 K2 @( Z* ]7 H* I& M* |
.leds = da850_evm_tl_leds,+ W3 X$ |: e* U. H6 U" R" ^: M
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% d0 m- U4 H" |# @1 ^) n- `};
' _9 F" i5 D" w" T2 j0 F5 o
" _8 I7 E d E. p" b; O1 k0 g3 |static void led_dev_release(struct device *dev): m( P0 F: z# A+ k$ i. ~ C
{ G0 `7 p$ I+ F0 B! f9 K6 \( j
};
9 E+ S4 A! V( r$ Z" c) o8 g( o) ]- ]0 i# v0 C6 Z
static struct platform_device da850_evm_tl_leds_device = {
, r G1 y2 C2 x/ V .name = "leds-gpio",) s' f$ q, i V3 `
.id = 1,' d4 G' V4 q7 O6 R' j3 z
.dev = {
* g5 [6 s$ \; B/ { .platform_data = &da850_evm_tl_leds_pdata,. r$ |2 w) F6 F' Z% R
.release = led_dev_release,6 w: N) T. F8 j6 j8 j) ]2 Y
}
+ W$ i! r( G5 V3 {6 D/ a};
3 q% z" |( B' b/ P, s7 @
( V# p( I$ Z, O) r/ P. \. R1 tstatic int __init led_platform_init(void)
& E- L% x0 l0 \, j! z6 j+ E{1 B4 F1 l7 N( s. @
int ret;' U0 \4 L' V! [8 U1 [& o
#if 0
6 _/ B! M' O8 S' ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ]: |/ \ Y, ]/ l5 \6 a if (ret)
! I; P, `7 k8 _" v( w! H) x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: I* g) Z8 D7 E$ c "%d\n", ret);
' w( ^% y, y& _6 h1 H#endif8 B9 N! R/ W: K3 J* f
ret = platform_device_register(&da850_evm_tl_leds_device);
3 V7 h/ k) Q' r' l3 P/ I4 c if (ret)- H( l# ~$ A) P4 B- t; x ^/ r
pr_warning("Could not register som GPIO expander LEDS");" o7 V1 ~! q1 U" }) v* n. E
else
( o! I. X2 N8 k; G0 S% ~ printk(KERN_INFO "LED register sucessful!\n");
# N1 A3 m" N; c: h: n* z5 r6 f+ @' K3 r' ]4 @/ s7 U
return ret;
& C# R/ n' _* {6 T$ W; ]5 q}' `. o8 b. Q7 [5 V5 Q% p4 v3 [
2 T! a) S# W, [" k" v
static void __exit led_platform_exit(void)
% O4 m, a& I' p ]{* I! m. Q& \, W/ b/ B
platform_device_unregister(&da850_evm_tl_leds_device);: N8 a$ y2 a6 s4 ?7 M/ Y
0 ^ C" G% I. H" |/ w) z4 x printk(KERN_INFO "LED unregister!\n");* B. n- h! _0 X8 f
}5 }, S( S) i+ [4 p) ?, Q
( p' e( |$ O/ O3 I1 Cmodule_init(led_platform_init);6 [! P* s# s/ P4 S: L5 _- w% M6 `6 b
module_exit(led_platform_exit);- y( R+ `0 x$ z2 Z
9 T/ q8 X6 l' [' gMODULE_DESCRIPTION("Led platform driver");
7 V' F) }$ x I2 S2 N9 lMODULE_AUTHOR("Tronlong");
% x5 M& m" m, }9 }1 U8 ]3 SMODULE_LICENSE("GPL");
( c- O0 u4 e: x: v) N" i1 u3 h; q! L8 j6 h6 H7 |; z
|
|