|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 y' F3 M1 i& H9 b#include <linux/init.h>
, b: w s/ n( M# _#include <linux/module.h>4 a3 E- v% v- @$ n% R
#include <linux/kernel.h>
# a# ?+ D4 ]# e3 I#include <linux/types.h>
( |, z: U* J) r4 S#include <linux/gpio.h>/ d7 k1 @ }! g9 @. _% S% b
#include <linux/leds.h>
/ x, l" r) z- A$ A! e#include <linux/platform_device.h>
, X- `/ x, b+ _$ x. x- ^, ?
8 |3 I3 D8 n* ~: I p/ o k#include <asm/mach-types.h>9 p7 E, X- f: w% q' } l8 u
#include <asm/mach/arch.h>
* P/ F I$ q7 B8 W#include <mach/da8xx.h>2 O6 ^) D6 q( q+ c+ [
#include <mach/mux.h>
- y5 ]- u$ m! R c
% o3 l0 Z' l; L0 [1 v6 M D+ M6 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 n$ H8 C) u) P% l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 K/ w9 V/ h0 O) Q7 j- _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 `4 [+ t3 `- A/ B6 m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ `7 C6 M% N0 O) W1 n5 u) Z( @ Z w7 v% G% G0 Y
/* assign the tl som board LED-GPIOs*/
1 m; ~* n3 \# `4 w! zstatic const short da850_evm_tl_user_led_pins[] = {8 T) t9 b% ~, h# g* G* Q
/* These pins are definition at <mach/mux.h> file */
b' W9 u Z- I1 M/ J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 M# ~# W0 ?/ h8 h z
-1
5 e8 H* ?) }$ [6 N& |};# O" p1 f/ ~% G
g2 U. W, Y" z7 \
static struct gpio_led da850_evm_tl_leds[] = {
5 O2 Z! J( v" O" j6 Q; v! K9 P {
& a3 |# f3 o, |# `- R' h9 B6 C% m7 ~ .active_low = 0,
8 X3 w7 J/ F& R .gpio = DA850_USER_LED0,
I3 J! H1 v3 t0 E9 V5 h: q .name = "user_led0",2 S( q5 I; j: }; H2 I, J+ }3 m
.default_trigger = "default-on",* e, g0 f% t1 t2 Q
},
, L0 E1 Q8 u$ @: u" B( M4 J; R {# i0 w4 p& A6 g* N# D+ j$ E1 c
.active_low = 0,# |$ t2 T; z5 P* w
.gpio = DA850_USER_LED1,
" u* T9 z5 f& g .name = "user_led1",
% P; u7 g) v/ v, f .default_trigger = "default-on",
% [1 @2 O$ b' B },
, J$ d. I8 v. S& [1 o- a9 c# K {
" r8 I/ Y6 r/ e .active_low = 0,
2 a. D. R5 V$ g) Q! T0 h7 e .gpio = DA850_USER_LED2,
& z3 S M7 A/ `% R2 z. x .name = "user_led2",8 J4 l( P# O4 C% o+ p
.default_trigger = "default-on",
# o' i6 B3 D. ~$ |8 A+ S },
8 t" W+ A" {# H; U. `( V' u" {+ { {
( T, n9 S! A1 P7 o .active_low = 0,
, H4 S7 z) L- v( Y3 r .gpio = DA850_USER_LED3,& d' D {* S; ` U& p$ ~
.name = "user_led3",
6 z) A7 `8 D7 y" o* A: y3 W0 B .default_trigger = "default-on",
( G' ?* i) C. r9 L+ G# ]' `/ z3 d' c },
S {9 p+ b3 d, b$ t2 P* p7 L};' P0 U0 N# {' u8 i7 m
/ c# D. s. ^9 D4 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. C5 M5 L! k# A% X* B7 Z; d6 p% e- R .leds = da850_evm_tl_leds,
5 z( F$ x& @* r! z; s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# s Y3 B8 X. Y( l! B( ?. e};, G; Z/ ~* N; @
5 ^" g. F& s; K; v6 Z! W
static void led_dev_release(struct device *dev)4 A/ Z8 w7 ]( u8 t; E
{ A+ w1 g/ d$ X( a j. I" j
};: w# A$ `5 G. `1 ?( E8 L+ `" U* O9 g
" ^& b+ P6 P; ^% X" c, Z# l wstatic struct platform_device da850_evm_tl_leds_device = {
+ z5 j; K1 s8 I2 V. V .name = "leds-gpio",
' x# p$ h6 \# Y1 z. ^( I, F .id = 1,
* ^& z# c; s# T# q# ^" r! R .dev = {( z7 [" R$ n) J4 a$ Q" I
.platform_data = &da850_evm_tl_leds_pdata,% e6 f8 n: R3 v) H, _% A
.release = led_dev_release,5 g" K/ m; I' f& C
}& Z4 h- I8 r& P% h' }
};
7 H& B ?8 y% R" Q
5 b5 p. O Q9 ~+ N" Pstatic int __init led_platform_init(void)8 n6 w! o# a% Z7 C( `: B! ^
{, a* [4 U$ `7 u3 l5 b' b- f( y
int ret;( g# O- U" e0 [6 }- h
#if 0
. m( f& |6 p/ S' S; f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ {, R, K- N9 P! h
if (ret)/ l3 \; @, n4 ?0 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# n3 G; X- Q+ C) ~7 t) w( C "%d\n", ret);) u$ r6 J5 V9 `9 f- e/ m
#endif. S0 T1 X- \. w) t& b# Y
ret = platform_device_register(&da850_evm_tl_leds_device);
! K8 f u5 v# d( F if (ret)6 m6 z6 o3 u" k* e; h
pr_warning("Could not register som GPIO expander LEDS");1 F" [2 L% B# B5 }- Y8 q" _4 L1 O2 C
else1 L5 T+ G' P& Z6 s' [
printk(KERN_INFO "LED register sucessful!\n");
- e) Z' \) v) D- \( R* R" y
8 k# l! b* r; l" m8 h' N' S return ret;
1 b) @9 a8 N( y- m}
! y% h1 k1 E5 e0 X* U, i3 t
/ x- I" x, H3 X/ Bstatic void __exit led_platform_exit(void)
. Z9 u0 f( A# B/ f+ P{7 y& S! ]0 \ A" O* i9 v; B, q0 J1 j# B9 G
platform_device_unregister(&da850_evm_tl_leds_device);
+ ?0 D S2 h: D7 i5 E
, ^+ E) c# @& [+ l) L printk(KERN_INFO "LED unregister!\n");- N r3 z; H; v' _
}, |6 H0 k) O2 P2 _
) r" H3 J9 J: [' u
module_init(led_platform_init);
) M+ U) ~& b: l5 l+ n! }module_exit(led_platform_exit);
8 y) D2 k- F5 }( l6 Z
+ B* G+ i1 T; @MODULE_DESCRIPTION("Led platform driver");( n9 [6 K& i3 r" e% y! J% V5 s3 K
MODULE_AUTHOR("Tronlong");
$ u- q7 a3 m; O9 Z% ]( e- @MODULE_LICENSE("GPL");" S( a/ P9 ]/ b/ x" e; l, v4 a& [$ J
2 W0 ?3 k' z9 K% c
|
|