|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' ?6 t/ `: e- C#include <linux/init.h>' K0 L+ e, N6 @/ E S1 K, m6 v
#include <linux/module.h>) G- G" X6 J/ U$ r c
#include <linux/kernel.h>3 s& e% L+ c0 `4 u+ o( Z& J
#include <linux/types.h>
E3 r: h$ _! W3 r5 v- Q# ~#include <linux/gpio.h>
- E1 |' Q0 X: b5 `#include <linux/leds.h>9 r/ B7 C6 K& Y. x* q& G& l2 e* T: H6 Y
#include <linux/platform_device.h>
+ j5 \9 ~$ u$ S& p1 F
8 f2 A' j" O2 |, Q% O! g8 v) y#include <asm/mach-types.h>
1 t4 u: n% ?3 y& m+ X" p4 Y% A. I#include <asm/mach/arch.h>
J ?" k$ q( ~) |/ U' k! y6 p#include <mach/da8xx.h>
7 d5 E. x3 d1 y* \9 |#include <mach/mux.h>5 W+ ^+ d6 \4 o( p: o5 j `
* L, V* e. P& o8 x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' W7 w# c9 j9 B. g& }4 s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& z$ _* ^/ u" W% t" j" J3 V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ s" l: V& k5 ?7 e+ p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 ^( N4 h1 v% |+ Z" @
5 G1 Y4 M$ W# u1 c0 l# L# ]( N/* assign the tl som board LED-GPIOs*/
3 `% i" y( X) c& Wstatic const short da850_evm_tl_user_led_pins[] = {
- r) c# L6 N$ ^0 n- u. m7 h /* These pins are definition at <mach/mux.h> file */
/ ^3 Y4 n3 o2 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 c- ` A0 h } D. ^2 ?
-14 @+ Y8 L6 ~ h- w4 G" ~ F
};7 h' e- a; r( a8 P
2 K5 r) G* V# `( W; l2 X3 k4 istatic struct gpio_led da850_evm_tl_leds[] = {9 g# D, j4 |, r* Q4 N" f) W
{
1 T0 G' {$ R+ n% G .active_low = 0,) D( C% d$ }6 I3 X0 P' ^
.gpio = DA850_USER_LED0,/ n( N5 ~3 `( H% N
.name = "user_led0",
' Y) k- \; T- R/ p* D .default_trigger = "default-on",
9 \: t2 m, ~0 u, V },
; p9 b1 @' b- |0 ^9 G5 s {, }, }2 }2 n& U7 {) T
.active_low = 0,
0 K# i- w2 r! s4 k2 }! a .gpio = DA850_USER_LED1,
% t; y; v/ V3 O8 \3 ~, Z1 C/ M .name = "user_led1",5 s- y& E7 t8 t) M4 F
.default_trigger = "default-on",; r$ G: |6 d% _; Y! N6 q
},
) S1 w3 E; a, I: T1 V( p5 L {
% J: N( C, U0 w* C .active_low = 0,
% ]4 f* n% n$ ?- l .gpio = DA850_USER_LED2,
2 A" {; Q# b8 p6 M$ Q5 K( A5 U1 ~$ _ .name = "user_led2",/ u+ E- ?& Y; U+ X6 T
.default_trigger = "default-on"," E( K) @8 l) U) A/ K8 d9 f* e
},( h! S! ?- h: t2 k) V& O. G9 j: |
{
1 F3 g: [9 M6 F# h7 Y3 o4 f .active_low = 0,
: `" V0 M& ]9 m, a4 G$ q .gpio = DA850_USER_LED3,. U" `/ W- Q# N5 \; k; k! m
.name = "user_led3",
6 j, K" i& d% }4 _" b8 A( r, i .default_trigger = "default-on",
# C. \# c/ {; R0 P* t) I; g }," |2 S( t) Y8 B- _0 m' o
};0 e2 ?% Y& v$ u# ~2 P8 a
h% J5 n4 X* S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { [; j) F2 Y' G i* `3 j
.leds = da850_evm_tl_leds,
! T! a1 y! H+ E/ L, n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 }+ ]7 j. P8 z};" L( `5 T) y4 O7 L' ~1 A# k/ N8 q
9 U' T' t3 }6 |" Pstatic void led_dev_release(struct device *dev)8 K) W ^1 g) |. Z% B9 G
{( r6 A+ ^. b# C+ n3 V
};
2 _5 W" K0 j: n* E( M) d/ B/ n! e5 [- {/ F1 X
static struct platform_device da850_evm_tl_leds_device = {: X$ A& m, f# k# v7 a7 _! {
.name = "leds-gpio",4 C3 M0 l4 A( M7 r" l' k# y
.id = 1,
* z0 U1 C+ f! s6 b2 h5 E3 v6 D .dev = {
8 W, l$ M3 r# ~& W, X' } .platform_data = &da850_evm_tl_leds_pdata,6 ~1 P9 @& s& }" l
.release = led_dev_release,
; X9 M2 ~- X( h, o, G6 d5 a( [ }
* B1 {* j$ z+ u9 b# x};' W2 E9 _2 f$ h! h5 c
6 [) I) {! b% C% @; }" l, b$ p
static int __init led_platform_init(void)
* _+ M+ a1 {# |6 @# { Q7 Y: y& c$ |' \{
3 \( m- y$ h( g" Y- X& Q int ret;
/ Y( b) y5 K3 G5 S% p) f- I Z9 _#if 0
1 s- `; V- j) L7 l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% k: w( x' }, e* {& N if (ret)2 u3 N, g: R: n, U# W$ o, }) L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; o& H3 r1 R" J, h; J! r% G0 a
"%d\n", ret);, S9 f. J1 x S. d0 v. Y$ p& c
#endif
6 h% A& ~) F) S1 n; X- F/ U ret = platform_device_register(&da850_evm_tl_leds_device);$ G4 @' D3 w, ~9 w1 D7 ]3 u" G9 I
if (ret), n9 G9 P6 T" W$ K4 Y) ], Y
pr_warning("Could not register som GPIO expander LEDS");( S4 U) T) x1 w0 {/ T& r
else" z& ^9 H! ~: A8 G& k
printk(KERN_INFO "LED register sucessful!\n");
1 g/ `+ \' G; e9 ~1 G7 R6 k, ]1 I
2 G3 a; Y2 \3 f: w return ret;9 M5 @9 B* m& w) O! o1 p/ G6 U
}
" o) A# G1 k3 d$ w5 G0 |8 Y) a& R8 X3 ]) K6 |! N4 N" K
static void __exit led_platform_exit(void)+ F% ~7 Z, j' V
{( { m3 Y4 M* P+ ~; I" \
platform_device_unregister(&da850_evm_tl_leds_device); ]: p! d p- A2 K
) x0 y* u. O7 C' q
printk(KERN_INFO "LED unregister!\n");; G7 }# m$ m# B1 o+ h
}
& y* A; E0 Y# j, F3 a1 L5 t% u* y; @. |) i8 B' @
module_init(led_platform_init);: Z% L' w1 s0 i0 g! }/ C
module_exit(led_platform_exit);
) w9 G, P$ m. m8 h& B/ y1 R
5 C7 L3 S+ J/ @& ]8 T9 p1 GMODULE_DESCRIPTION("Led platform driver");8 K% w7 b- p9 h, L' |
MODULE_AUTHOR("Tronlong");
' ]$ ^* V q/ p- _1 @% a: PMODULE_LICENSE("GPL");
' o8 ~) ]+ P# J( f
9 I4 ]5 {) e/ a |
|