|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ T2 d* b j' u7 ~+ d#include <linux/init.h>; l0 D% P y5 o& w" v+ ]
#include <linux/module.h>
?; R; J6 R: o' g1 b0 |8 W#include <linux/kernel.h>
+ C$ Q5 {8 M+ W#include <linux/types.h>
. d/ w! T6 H+ @#include <linux/gpio.h>
" @: U1 Z6 O2 E3 d% d7 n( ~9 P#include <linux/leds.h>
, Y) L% \7 s8 ^' ~+ i#include <linux/platform_device.h>
+ K/ d3 T7 D* K, D m9 S; X* n; q" F2 w v: n2 @
#include <asm/mach-types.h>6 w$ I" F4 d9 c$ T! C/ i( K2 f
#include <asm/mach/arch.h>
/ A8 T7 Q9 G( v( Z#include <mach/da8xx.h>8 [- d. V( g2 b w4 ~/ `4 B5 Z9 x
#include <mach/mux.h>
4 @6 C* P0 |8 U. b f: Q# @: x3 T+ ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): w/ P$ |0 o0 l1 a" p' O n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 S6 U3 a" |; ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" k$ x! v/ i% C" G$ G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ E. _% B* s( n
S4 x D- o5 \( N/* assign the tl som board LED-GPIOs*/
9 S0 W+ h j; C& @, Kstatic const short da850_evm_tl_user_led_pins[] = {& J" I3 a# w; `5 A8 ~ e
/* These pins are definition at <mach/mux.h> file */
S1 V: i5 ]' l0 W/ Q) r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 z# Y7 H8 o! k/ l! `9 k -1
1 R1 g$ o2 [0 w/ ]- M};
6 c5 o+ ^, [" {1 b# r$ f- [1 k
6 B! ^1 \# V$ T' s; o" Vstatic struct gpio_led da850_evm_tl_leds[] = {
. H. o/ M# i7 O, R2 U3 u" b {: }0 [* }1 K! w" X
.active_low = 0,: j, H) a5 R2 S, i, O% s5 `
.gpio = DA850_USER_LED0,
( s/ X: Z4 O5 U" d .name = "user_led0"," a4 R; m5 i" O2 w' E* \* @" s
.default_trigger = "default-on",
0 v4 c. S1 l$ R* W$ q9 t },0 ^8 F* t1 M/ q( t# m5 t+ F6 O
{( V, H9 b3 ^0 m5 I
.active_low = 0,. V$ b1 Z. ?. i. E
.gpio = DA850_USER_LED1,- `$ _4 o* ~; d: c2 @7 r5 F
.name = "user_led1",
( K: y8 p y! ]6 T5 `, y2 E .default_trigger = "default-on",3 k& T x$ A2 f" c
}, J, p( {3 x" M$ Z4 T. c
{, x4 A& y) A5 e% O7 \
.active_low = 0,9 C% A% d: u0 r; p$ i7 T0 C( A
.gpio = DA850_USER_LED2,/ h4 J5 s2 t% j) d
.name = "user_led2",
7 {% G' _- t* V3 f6 K4 U J .default_trigger = "default-on",4 o- z3 v6 X \
},
5 G& \. D& Z- c+ X" z7 W9 n, K- v {/ ^" D5 a7 z" ] r. z
.active_low = 0,. d' {( T O! W' u2 K# ]+ Y9 M+ m
.gpio = DA850_USER_LED3,) c5 {% A/ n5 ?1 T/ A X4 \
.name = "user_led3",
# ?" ^/ r% R; j7 T7 n/ E' J/ i .default_trigger = "default-on",
0 g( O4 |, O/ v; F% T# j: l },
1 K3 A4 G# D3 @2 Y7 f$ D};% B* v9 L# K4 Z( J; h8 P( T. ~; M- R
' s0 f2 ]) c ?0 E# lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 a& a; e6 G: Z1 g/ M
.leds = da850_evm_tl_leds,
. ^6 [9 K/ a2 r* Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 |. R' S' M4 b( @' _) b
};; G$ Z, T$ C: z: A
9 F' e \0 H4 m9 t& i% P( f8 y O
static void led_dev_release(struct device *dev)
$ t, n- y- c( W9 P{3 Q. {2 R4 `6 I
};
" o0 h, b! J; y, N/ \# e
' R2 j) }5 ], M$ @0 {static struct platform_device da850_evm_tl_leds_device = {
* }5 l# e9 U" Y .name = "leds-gpio"," c- a5 `' v& }
.id = 1, k# L; T; h& d$ h* R/ w9 O4 n
.dev = {3 L6 m Z1 n" H6 p. S3 K
.platform_data = &da850_evm_tl_leds_pdata,
% l% z# m- i0 ] .release = led_dev_release,
# G4 p6 d4 o, _4 Y }
/ D2 O; l( v, w" d9 i" I; |};) Z( R, f) D6 t5 {9 X& u$ F3 R5 G4 Y4 L
# g8 R! Z- l' H, Bstatic int __init led_platform_init(void). V4 i& n0 F! \! x; A3 W, S
{
) ~& I8 p2 ~+ l1 p int ret;
4 _( g' m) a3 u, P+ H#if 0
3 j; C2 E9 o9 {2 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 Z Q: P+ Y/ R+ t8 }' c
if (ret)# v; Z/ s8 F) ~8 `" o% o) ]5 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", L7 j4 W5 i' l2 H
"%d\n", ret);
* b! y8 ~5 g v R#endif
9 A; ~2 O1 e9 ?( g W; V3 g. Y0 \ ret = platform_device_register(&da850_evm_tl_leds_device);5 c3 R1 D# R/ |# `
if (ret)% k, O6 k! K( e* Y5 X& b# r
pr_warning("Could not register som GPIO expander LEDS");
2 A. U9 F' I6 d, @3 ?8 f else
- b- V9 C, q6 N printk(KERN_INFO "LED register sucessful!\n");
$ A- |; r% ]7 |, V: ]- ~( N8 d/ l! [; U/ g t w! y- B. S
return ret;
4 X" l/ l' D+ X+ f1 t( U( {; U}2 V; w' E( l+ D% M* S9 J9 w% L" T6 v! b
/ @ X" n- U; t, z$ Jstatic void __exit led_platform_exit(void)
6 c, M/ v8 B. }( K1 G" }! h{( [/ b# ~8 O, l1 A" o
platform_device_unregister(&da850_evm_tl_leds_device);" x) ?7 `) j& k% p0 `
5 O3 Q) w: |$ L- B( G
printk(KERN_INFO "LED unregister!\n");. b9 I; n) H! g1 n p; w5 {/ D
}
) m' f* E5 `: D0 W& e& C! R0 R# G( N" w3 h: G1 X3 u6 X0 J
module_init(led_platform_init);3 o5 d' g: p/ d
module_exit(led_platform_exit);
$ d; S- k8 x' s4 v4 @! ]; }) K4 j }5 h' ]; v) I3 w
MODULE_DESCRIPTION("Led platform driver");
. G$ \; ^- e" w: T: Y; z1 C6 w0 iMODULE_AUTHOR("Tronlong");/ T; a/ x. @! n! P0 P, C
MODULE_LICENSE("GPL");% } C2 T% _/ w! x! _# W: T
4 x4 A4 {$ D, P |
|