|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 Q5 E( c" U4 q ^#include <linux/init.h>4 I, ? s) o. n# ^1 ?' m
#include <linux/module.h> k( a6 k8 {, v' [+ X3 ?
#include <linux/kernel.h>
h- i- v0 k; T* o#include <linux/types.h>
! B; G c3 J1 u+ {( I( k1 F#include <linux/gpio.h>
& `, C# e3 i1 _/ y* I- n#include <linux/leds.h>. z0 ~& o0 q. K* B7 q
#include <linux/platform_device.h>
, d5 h! E. R: W8 S; m0 \( K5 [" P: y8 c! R
#include <asm/mach-types.h>
6 Z, o' N1 w O" ?7 E. K#include <asm/mach/arch.h>
: o% ]( T& r& w% Z4 @, Q#include <mach/da8xx.h>
: |# ?0 ^2 M7 g% \#include <mach/mux.h>+ u( Q, a1 I, s# T* q1 J2 d+ y
3 X( z7 Y3 T8 e/ J" B3 S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) @) |/ S" {; L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ @) F* o' [) d+ s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 |% l. Q" r6 U& }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) l; B# X' L( Q* S
! X& Q p5 ], L
/* assign the tl som board LED-GPIOs*/9 r8 v% e8 J$ |9 x4 r! f7 r
static const short da850_evm_tl_user_led_pins[] = {
, b) t0 K6 w& l3 k$ [; Z, O% @ /* These pins are definition at <mach/mux.h> file */
, \% R- W% M# j0 U7 F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. R# W1 o9 |, j. Y2 I
-1
* U9 Y2 _: c" J* h u};
7 B) R8 _* E) ?6 I; |: X" X. ~( T& e8 t
static struct gpio_led da850_evm_tl_leds[] = {
, T2 O' [: s, E {
9 X) M+ w. A Y2 T! ] .active_low = 0,
! R2 H* E3 s9 h .gpio = DA850_USER_LED0,
: e2 j% A' ]6 ?& S7 y( j! J6 [ .name = "user_led0",/ z# m, ]4 i# \8 {& O
.default_trigger = "default-on", [9 n% H& V6 K% ]- v8 A
},
5 E# f7 c" f2 G3 Z7 l$ q {7 d# Z# _/ u: r4 ^8 L3 O7 Z
.active_low = 0,3 A9 ]* p5 f- c2 S/ f2 j9 A7 J
.gpio = DA850_USER_LED1,- I# E: k* `* z$ E" ^0 C. E
.name = "user_led1",
2 ?; c3 Z5 u" h' r, U1 x .default_trigger = "default-on",
) x1 H( z* k6 L# X$ h, n" ^ },. l) }4 v: ?1 p" D
{
( R, q% _& R9 S" E .active_low = 0,1 k+ \3 ?- M. z, f/ V8 f7 |% O) z+ A
.gpio = DA850_USER_LED2,
" e! S. T4 ?: m2 g .name = "user_led2",; i% Y8 i; q ]" y
.default_trigger = "default-on"," o3 ^+ R9 I2 W' W0 N* S
},
) d* I7 ^$ L# N( u {
) c9 S9 c/ E9 V# t, Z) j .active_low = 0,
2 r4 _: k3 r& \1 o) o( W .gpio = DA850_USER_LED3,% r, }2 k1 C0 C5 _, ]
.name = "user_led3",2 f( a( H! |, i) G: k' x
.default_trigger = "default-on",
# @3 N" R2 _0 K. Z },# x) g! U& B- D- u1 q, S
};
, G+ D' W4 E" A2 n2 {, ?# F! E+ _* x n8 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ E- A( d1 Z7 C
.leds = da850_evm_tl_leds,. e" s: u1 i X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ q# v7 c4 k9 a, ?
};
% m) M0 e, Q" X
$ D. |: ~1 i* T8 ^ i vstatic void led_dev_release(struct device *dev)1 Y" ]6 N+ G/ Y9 i* }) n) {
{
# A7 o' M- H/ |# J* A};, k) r; P. H+ N
& j, _: J8 E$ J3 W) u7 rstatic struct platform_device da850_evm_tl_leds_device = {; K3 s3 h4 H' [" M; s. K& N
.name = "leds-gpio",
0 X* x. U9 ?9 y8 h9 k .id = 1,/ `: h1 A7 w6 `+ F0 S! s
.dev = {1 `5 D" P! M- y- t. n
.platform_data = &da850_evm_tl_leds_pdata,
, v7 \% l: `: s5 x) k. P9 h; ~ .release = led_dev_release,/ w4 k- X |# ?/ B6 m" c
}0 L! l, \8 X$ t! ?5 v) X3 H
};
* }, \5 Z2 [& J8 O+ ^' v9 _! {: ?& k2 _, s
static int __init led_platform_init(void)
B3 w# C6 ^: Y5 K{
/ s% h' b# [4 Y1 S int ret;- s1 g2 t& `' |5 m% h
#if 0
3 Y5 W" G* i7 a7 M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& `/ E+ F9 d4 I) Z2 Z/ t( g, t( D3 C
if (ret)
' w& \, W) v. O: U6 _2 J9 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 @/ }$ F: N* A# t- q) Z3 u6 E
"%d\n", ret);
% f; \: }" P! x' X$ F% _# `#endif
" H0 o! l9 I& K4 U9 S S/ v7 S; D. E ret = platform_device_register(&da850_evm_tl_leds_device);7 t/ M' }; r, l
if (ret)6 B( Y. I+ V3 ]8 K+ L
pr_warning("Could not register som GPIO expander LEDS");
z' z) a @; n: v7 Q- R8 M/ |. c# \5 E3 @ else
# X8 p1 i/ Z V/ v printk(KERN_INFO "LED register sucessful!\n");4 M) y1 n* O e' E! B# h
) j6 u- M6 o4 P4 P" e1 G; z return ret;
: w. @& B" p* A& n8 F. N6 k2 B- q4 b4 ^6 W}5 E! \% _- s* D: b* ?
) p n: R6 Z( H m
static void __exit led_platform_exit(void)
v$ j+ ]6 b: ?2 ` y% H! o{
9 x) Q% ~) G1 F: x/ Q! z platform_device_unregister(&da850_evm_tl_leds_device);
2 L$ d7 g- O5 S) m/ Q0 U o% \, ]% k! [4 K
printk(KERN_INFO "LED unregister!\n");# i! C" W. F7 {
} ^) `1 Z) A. W
& J7 |/ A; {8 j% w" E
module_init(led_platform_init);
; k* D. Q# C/ q; i8 W% qmodule_exit(led_platform_exit);8 n- E' W% Y0 V$ F: C) u
9 ^( N& U# U$ w1 E
MODULE_DESCRIPTION("Led platform driver");+ p9 g3 i& @6 z& t7 `
MODULE_AUTHOR("Tronlong");
+ C" }8 o$ R; d4 A& F0 JMODULE_LICENSE("GPL");
* }& {# L- }/ H& v7 `$ I% ?/ N4 k3 T* _
( x+ _3 c# j0 l- F9 [! x |
|