|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, @$ d4 T1 w7 L3 g* _8 d
#include <linux/init.h>
; h* R& Y6 B, }#include <linux/module.h>( y t) F4 [0 d7 M" b. y
#include <linux/kernel.h>
7 [7 ?0 X+ T+ Q#include <linux/types.h>* ~/ ]2 y) \& G" l9 e( p. f7 K
#include <linux/gpio.h>
% d4 T: E' C0 C* e1 u#include <linux/leds.h>
5 n7 \5 h/ @! P3 g0 O* ?1 k2 a4 t#include <linux/platform_device.h>
6 ` ~' y3 F! p$ r* n: }7 q
% B+ H8 v0 o/ H; Q#include <asm/mach-types.h>
. [, g C, u( j; j6 D. I$ _#include <asm/mach/arch.h>
, U/ m( I2 d/ H) _- y" w a( u#include <mach/da8xx.h>
6 A; f/ _7 r0 ~9 b/ p: H#include <mach/mux.h>
4 L$ h! \0 e C+ H- S9 o
9 W& a) O' a: h4 k; R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 j9 _& v8 {. o7 B6 s0 l$ A" I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). }7 {: ~( ?" v( [7 t8 [: [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; P! t1 c. x7 z# S- {& d#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 b7 B$ n& u* D# s, ~! U( ~. R( o2 Z2 Q: }
/* assign the tl som board LED-GPIOs*/
3 f j: V7 b+ nstatic const short da850_evm_tl_user_led_pins[] = {
1 g, o, c6 h8 K% c3 t; K /* These pins are definition at <mach/mux.h> file */) t/ A* }7 W- H% x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" c+ S! @- l% d9 O -1
* N3 U7 @; H3 y; k};
* ~) P4 B2 g+ Z- y0 N# E6 ~
6 i/ P8 j. z" r2 _% M1 Gstatic struct gpio_led da850_evm_tl_leds[] = {/ o, O8 i& b" ~6 t1 x7 A
{+ k7 y& p1 z6 B1 a# s
.active_low = 0,# n, k1 z) o% w7 a) H
.gpio = DA850_USER_LED0,
1 q! V. V: l/ [# b/ F .name = "user_led0",5 ^8 \$ Q; a* h2 g: J/ K4 B$ X
.default_trigger = "default-on",1 i% q0 S. o: F8 b0 S# W
},9 X5 g% T7 [4 b
{
5 P Z; @8 @/ ^0 d .active_low = 0,9 A5 B1 K0 J8 D v7 v) g
.gpio = DA850_USER_LED1,
% K; x" k. ?) ` w2 ~9 d) ` .name = "user_led1",
' b8 q' j( j$ W1 b9 s2 Q3 v .default_trigger = "default-on",5 g% V: ^+ c7 N
},: a* _1 ], Q( R9 o; ^( d: Z% ]
{1 k! X# S# X5 M
.active_low = 0,
' d' G2 D9 Y7 z& B .gpio = DA850_USER_LED2,6 r8 c; u. W0 D( @" n) [7 U1 w' K, r
.name = "user_led2",* z- e* f/ L! N: ~& l5 g
.default_trigger = "default-on",
' H" y+ k6 l- Y' N0 u/ { u },
. ]6 k3 ?: J' q6 v {
1 g+ _: D* P( o2 k0 }9 m .active_low = 0,
+ ]& d0 e k! T& d .gpio = DA850_USER_LED3,& j: v7 G/ S7 @9 V) e; x) L
.name = "user_led3",2 p% L0 u/ u/ i# W8 d C8 E
.default_trigger = "default-on",. W' i3 Q; t+ M8 F; ?" B( N( x. I
},
+ h6 M& }. x! L; c: K};" z) g0 }. |( z/ U( K
0 Q+ _* t$ l$ Q9 z- Y$ U* a3 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 `# C" @ b; @& J! B0 A5 c
.leds = da850_evm_tl_leds,8 d6 x2 h, W' ?7 t M/ x5 j9 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), h+ y$ L H- y; e$ ]
};
$ k( G' K* i6 _" c2 a/ a3 M
; e) _+ z% b6 f8 bstatic void led_dev_release(struct device *dev)
8 Z" G3 e9 [1 w4 ?{* b% n( _: K2 I5 R4 v. U( ~- }
};
0 ]0 ~3 P' q9 j1 f9 L6 E7 X; t* q Z3 @+ r/ {
static struct platform_device da850_evm_tl_leds_device = {+ z9 W+ {3 l, @+ F
.name = "leds-gpio",# Z4 e3 \5 F* @& U/ T. |8 \( H
.id = 1,) A {- I/ h! F! F/ {; G2 w
.dev = {
% l3 }6 U+ k) T .platform_data = &da850_evm_tl_leds_pdata,
6 T* S+ o0 S, T# z1 a, m5 y7 U .release = led_dev_release,) R* M7 I* ?. r# |
}) f7 |, e9 s4 x, x: R
};
- @/ [/ }) c& P4 x6 L( R% S" O! |7 v
9 Q6 R. b' q% H' R) H( J/ z# Sstatic int __init led_platform_init(void)& B# g+ l8 w5 n+ N1 g# S+ z- i
{
& v7 O7 O3 |% Z3 A9 H int ret;" e% c6 [( `4 h
#if 0, K' @$ J' m- m; \4 s6 G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) ~0 c3 {! ^. E1 T+ M+ ~; B; h, Q
if (ret)
P1 f" Z% _/ m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 p$ i. @( |+ x9 J% y) U "%d\n", ret);
$ |& x9 F% m, p; M. P) t) D#endif+ e6 \7 l, d+ i! [, j
ret = platform_device_register(&da850_evm_tl_leds_device);2 O' g8 Y" o6 H$ g7 d5 V
if (ret)1 a X, e4 w7 M
pr_warning("Could not register som GPIO expander LEDS");/ u h5 \4 p" Y$ _, c
else
6 W% |+ z% R' j- \( [' B printk(KERN_INFO "LED register sucessful!\n");
}& s3 k1 C" R& g) ~" N3 i4 w9 x& ~) _" I2 y& n1 a: ]/ {
return ret;% B1 Y! |$ k" L ~$ k# q% k; M [
}6 w2 \' k1 \: K& m) K/ ^
. Y3 x9 J- I/ I lstatic void __exit led_platform_exit(void)
0 V% P" s4 G: a" K7 v{
6 B0 V% [. G& K platform_device_unregister(&da850_evm_tl_leds_device); m7 m6 U% B: [& K5 n ]6 U
9 C/ f; r4 u2 Z( f* D9 o2 i+ B2 a
printk(KERN_INFO "LED unregister!\n");3 N: B, q. p% [6 O/ H `
}
7 }8 _ V9 t' Q6 Y) e7 o- ?4 v7 b+ p+ F7 u
module_init(led_platform_init);9 A6 J& h: h" ]; g, V
module_exit(led_platform_exit);- F$ I1 ?$ D+ |8 k
3 I3 u- u1 Q0 Z" }( e; d
MODULE_DESCRIPTION("Led platform driver");
& G5 a% X) A3 }4 \9 S8 dMODULE_AUTHOR("Tronlong");
8 f/ e6 j* Y% z8 @% qMODULE_LICENSE("GPL");. u( \; X4 G- i K: \0 W4 s
$ u* H. s. w5 \9 W. B: q
|
|