|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( i+ c' a# P* }6 _4 ?#include <linux/init.h>/ b5 B2 ^7 w: c. `/ [( W7 [, Z
#include <linux/module.h>: J R0 q0 U( r) A; S
#include <linux/kernel.h>
, ]7 D l4 F" v: ]$ I( X" `5 |9 [0 `#include <linux/types.h>
9 E; k! r$ `) x' H#include <linux/gpio.h>$ F0 @0 O* x( x# X" O$ ?
#include <linux/leds.h>
5 R# G0 d" C! p- Y' n#include <linux/platform_device.h> `3 x+ h/ L# ]' t# e
) @& v* e: I5 E: R/ b) M
#include <asm/mach-types.h>
( c) {. v1 l! K6 A; n#include <asm/mach/arch.h>8 h0 }% `4 x! r& E
#include <mach/da8xx.h>
|' O: p% F0 M9 E* O5 }8 o+ z2 o- f#include <mach/mux.h>
) K& k5 |2 P: W% b8 g6 B5 K# D5 Q
3 t3 [* h& s* `( Z! I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# c Y, [- B/ X7 @6 g# W- A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. B% S- S9 _: A% {+ P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 J8 Q' |: j2 m& x0 r' j8 C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. P& v4 h- V! a, U; d1 F+ l6 G( r4 ]# b$ b$ l5 @2 ?
/* assign the tl som board LED-GPIOs*/
+ ]* J# L! v" F/ X$ K5 t' V2 ~static const short da850_evm_tl_user_led_pins[] = {, u9 q! U6 H6 H2 ~
/* These pins are definition at <mach/mux.h> file */
7 J9 m8 H E$ t' p1 B" g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, l+ Y2 u" Q6 B, e" K" { -1
3 k; K* x! l. H+ ?};4 O3 ], p8 {3 q0 o% A* u
* z# a- D! h0 h/ a
static struct gpio_led da850_evm_tl_leds[] = {
/ Z" D5 J( y' ]5 W1 W: a {6 [) X' z0 R1 c% x
.active_low = 0,
+ ^0 e! K: N% ?" R9 q: H! E( `: C .gpio = DA850_USER_LED0,
. _; C8 X4 R2 C: ?: E; o$ u* C .name = "user_led0",
) t7 L9 s# k4 i& a0 x* p1 m1 D .default_trigger = "default-on",
% O; G+ A# U% x },0 I0 h% n" N) K. F$ p5 t5 t
{0 j0 Y' c$ j4 q% ]- k
.active_low = 0,
" J& }) J9 H4 o$ w! N .gpio = DA850_USER_LED1,! E6 ^9 y1 n8 T0 A, U. a
.name = "user_led1",
0 r; k9 s3 }- b4 k; J5 r .default_trigger = "default-on", J6 F- [: h5 e( O" ^
},
7 h4 c P9 n9 O& ?6 N {4 E5 D- g# _ B% I. ~8 K
.active_low = 0,1 C7 e/ D/ f6 Z
.gpio = DA850_USER_LED2,# t8 H9 }8 n) B
.name = "user_led2",# Y+ G% U' N5 @4 _& Z. J1 c" \( c+ J; d& @
.default_trigger = "default-on",
# u1 Q7 u* a/ D8 S, S4 F },5 T, o# y. M! G9 {. {
{ }9 G% U2 ]& k- f9 [
.active_low = 0,
2 x# W: y! t; _% i; D: x .gpio = DA850_USER_LED3,
4 L2 @8 \0 L7 f9 h .name = "user_led3",/ E P' r+ R6 K8 M; z6 o: u
.default_trigger = "default-on",- j% n/ l1 ^8 v
},
3 v& p j% X3 u- o6 r# a};! F+ W% U* h1 r3 \2 _( T' x
0 a) x0 H- D {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) N& u) X0 l" Z" K& E$ V; s .leds = da850_evm_tl_leds,
! Z& Q0 D! Q5 L) R' L5 [+ Y8 ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% Y% w, Q, E9 d' s, N6 w' X4 F- D
};
8 g4 S. }$ I3 r9 Z9 y2 x0 p" c
1 b/ E2 ?1 |; f' w2 d5 W0 E' E1 ^static void led_dev_release(struct device *dev)
4 i8 s- b% C0 w; B{
& w; D1 H; @' o: q' g7 [5 k};1 y. j% A, E7 p ]1 ^& ~# S& B1 |
1 b X" b6 e, _6 |* a4 Qstatic struct platform_device da850_evm_tl_leds_device = {. H7 i6 i/ ]0 x' ^2 @4 P n
.name = "leds-gpio"," _+ R5 @3 w( R1 K+ W! ?
.id = 1,% {' `; e$ b' K1 h1 [/ k8 L
.dev = {% @. w8 T( W! {+ A$ X8 V
.platform_data = &da850_evm_tl_leds_pdata,
) O- ~# D7 l5 F" W2 f .release = led_dev_release,
6 r' `0 A7 [" C$ I8 P1 o }+ K8 c7 @, t. P5 n o! J
};& ^2 p3 L1 |) X& n2 L
7 q5 S$ D8 X' g; D
static int __init led_platform_init(void)' a! i! a* X% q1 e
{: V5 U# C& J6 u/ z
int ret;) a2 ~0 L L7 c$ n4 g/ s7 E) c- T
#if 0
! N# Y& T( j( j- b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 ~! H( p; b- M/ K$ t' i if (ret)& D5 R2 a0 @! Y8 a+ o9 m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 {6 R5 R9 Y) M3 i3 Z+ {9 i "%d\n", ret);
! i% N" k- r0 E#endif
! b4 g: v1 b" s' t, E4 ^, B6 Z1 P ret = platform_device_register(&da850_evm_tl_leds_device);) H5 [1 z t7 F8 T
if (ret)2 }$ g1 \1 A* f% G9 P! y
pr_warning("Could not register som GPIO expander LEDS");
) C8 a- A4 M, A2 m7 h- L3 Q else7 U3 p& p: x _0 w2 K. d# s% w1 [
printk(KERN_INFO "LED register sucessful!\n");
5 U" \( t; }/ [- b. N! y. q5 _; Q. @8 b2 C" p# I6 B
return ret;
4 a: T. D8 L+ m5 b}( o' `' ?0 ^) l* d: z
( k$ l" x, S. N
static void __exit led_platform_exit(void)
( h4 C6 r$ ~5 |# W2 d{
) K d: Z2 A1 @ platform_device_unregister(&da850_evm_tl_leds_device);
$ {4 H& S4 T+ a+ G6 m3 u9 L& e8 C; B3 W) g& }# k
printk(KERN_INFO "LED unregister!\n");/ f% V+ v, `% g: E
}
$ r0 C! L& y8 Y" }6 O1 r; H- x) l0 y" f/ f1 ~
module_init(led_platform_init);
7 P8 p _7 C) _' W% C6 f, ^8 qmodule_exit(led_platform_exit);4 X# R2 Q! u! J- @
) i; {4 p& q0 i
MODULE_DESCRIPTION("Led platform driver");( \) l& l6 @$ O$ B" P
MODULE_AUTHOR("Tronlong");7 C; {5 P* K/ c( p2 c' P, m
MODULE_LICENSE("GPL");
3 j# b2 A! v, v! j( y8 u4 X# Y, l
: I4 b! H$ K) C" n |
|