|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: I6 w; S8 ?8 h5 y1 _: v/ r: j. l#include <linux/init.h>8 W* j. S- x, r) L' @/ p9 y- J. ]/ q
#include <linux/module.h>
8 I2 P$ P; w0 W& y! c H* q* s" W" f#include <linux/kernel.h>
% V+ v1 g* ~* R- t0 E0 A3 W' F#include <linux/types.h>
' k! T- e- R8 ?* D4 Z8 z7 P#include <linux/gpio.h>* T" X- J/ c7 |" I0 t
#include <linux/leds.h>
. P" A* X* c( X! {2 \; }#include <linux/platform_device.h>2 q6 Y1 E0 y% j! @
6 l0 \' K+ J. o' q' G
#include <asm/mach-types.h>
) W e# j! l6 A' [8 F, x+ y% n#include <asm/mach/arch.h>% g' E3 Y$ F3 d
#include <mach/da8xx.h>
/ q3 l# ]: }- w$ ` S! A' R& W7 C, s#include <mach/mux.h>
& G- Z! D, ]& h- X9 e$ E
2 e7 U. z" K( s% j, n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 W& k8 U3 @' @1 F3 J) @# x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), ^1 |1 ], I' v* x$ Y. }( ]( ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) j: m: b$ z: ^1 d+ M+ x: U3 q) a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 Q6 E" q+ w, m0 O# n- t
( _2 e6 f8 |( t7 o$ o/* assign the tl som board LED-GPIOs*/
, E2 f" A' o, k7 ^6 Y' tstatic const short da850_evm_tl_user_led_pins[] = {
8 A2 j {- U6 h1 K n* O1 l, {* T /* These pins are definition at <mach/mux.h> file */3 c$ L# T4 `! S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ D; e" V: }3 J% q( J; x
-12 ? G" }$ z9 p$ y# s) i
};
7 D7 Y" k( @4 ?% I6 G. ~& A
& C$ M5 V( m6 I; |2 p5 `8 H/ k2 Jstatic struct gpio_led da850_evm_tl_leds[] = {
9 R, ? U- x$ F( q2 v) M, L* t {, u/ N' n+ d0 S* [! ~9 ^- E
.active_low = 0,+ f- ~2 P& ]4 w8 ~, Z& h" _( u m7 z( \) e
.gpio = DA850_USER_LED0,
0 i+ ^. }+ f2 b7 @+ B3 R% C8 T( \+ J' b .name = "user_led0",
1 L) W9 ]+ A+ ?2 r6 t; C3 k .default_trigger = "default-on",
. `% k- l5 E; ?% m! b9 J! n6 A, t },
& c1 J: ^7 ]! Q8 F# G; I {0 K# v6 h/ _2 l% C8 D
.active_low = 0,
' P+ B% A! P8 D3 D .gpio = DA850_USER_LED1,
7 W7 d* m* W3 M0 q, N% w .name = "user_led1",$ l1 x$ ]9 N* _7 `/ ^
.default_trigger = "default-on",) e. ~" v B# H0 T
},
( a; A6 p- v1 {; E+ Y& h {
4 P' x& j1 z1 H .active_low = 0,! c9 x1 v; t7 e( R3 V5 x4 m
.gpio = DA850_USER_LED2,
- @1 O; D9 t0 q+ P8 p8 S2 e) t .name = "user_led2",
7 r: O7 g6 g; K1 a+ w. G J% ]8 I .default_trigger = "default-on",
9 e/ y5 Q9 G4 O9 v+ g3 h },6 P: W7 @5 c; ?" p/ \% F6 I2 j: H5 e
{
+ w/ L& s' i/ K3 ] .active_low = 0,2 z7 w o2 O# |. U4 x t
.gpio = DA850_USER_LED3,9 z1 @6 r9 N( R0 J: T% j. v
.name = "user_led3",
6 c% }/ O/ X. k, u3 f) b .default_trigger = "default-on",+ m/ B6 m$ M$ a O' z) X+ T& V
},: |, S J5 w9 S; Z/ p
};
# ]% w9 S2 K% V! Y5 n r5 H5 X X$ j5 X+ j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, ~2 A; r1 b! k& ]% Y1 w/ g( o
.leds = da850_evm_tl_leds,
7 V/ r5 x) f+ [( o8 N7 `$ o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- u/ U# D: p4 T( M7 ^};
6 e- Y1 ]! |4 t' @! f
8 h, b! h- q- d2 | \# _+ D0 _' gstatic void led_dev_release(struct device *dev) X5 j+ D B/ D7 S
{. f: n' j+ b0 y
};) d4 C) }6 k# R( {! k$ D0 R
) ~- P z9 Z8 Z
static struct platform_device da850_evm_tl_leds_device = {
1 N3 S. H* j9 I8 l1 b .name = "leds-gpio"," e9 e' A% ?/ j; J2 c/ M) U5 y: D
.id = 1,2 p; p9 I2 o% r- N
.dev = {
( U% g) g9 R( z .platform_data = &da850_evm_tl_leds_pdata,
[6 i+ K$ H( `! J4 p .release = led_dev_release,6 o/ `0 d h; \4 C% H. v! d9 A) h: |
}
, G+ {4 ^& M* J' b b};" Q* W& ^7 C: e& }
8 L ^+ }8 X8 y* R* l: Bstatic int __init led_platform_init(void)
+ E0 C$ J0 J2 y' H2 @5 x{+ ]" M3 X0 i5 u- {, w
int ret;
% ] ]% J! x. H1 ]5 V#if 01 s5 Q1 v- h- z9 E! f. c( E9 I+ u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 `/ H- h) B1 G+ Y
if (ret)4 T" t s. u& x0 X4 W4 E+ {- M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# S/ U0 S* n" O6 j" k% b( O( K
"%d\n", ret);3 o' Z" ]1 O$ q2 x& |) Y
#endif( A1 {2 w; m6 b. `, P" d/ `
ret = platform_device_register(&da850_evm_tl_leds_device);
9 v4 M" l( X7 A9 D$ d2 k if (ret)
: @7 C% D' C1 @. e7 p& C! Q pr_warning("Could not register som GPIO expander LEDS");7 ?" i& U- N' k/ y; b- C7 W! s
else! k. a% ?, E5 [ W/ K& r7 Y! A
printk(KERN_INFO "LED register sucessful!\n");
% c8 O2 @6 E+ z4 u- m$ x
% F# a2 p7 n2 Q( w' c1 A8 T return ret;: {" M5 l# f5 g/ o4 D b/ O
}
$ Y: E8 b0 E# q* q1 [! o U5 q$ t" N+ z
static void __exit led_platform_exit(void)
- E7 ~* t9 N& D$ ~# ]{
; Q+ [0 I# {- G platform_device_unregister(&da850_evm_tl_leds_device);2 \% g! K5 d3 {3 ~: o( ` }
. ?4 ]0 ]. Y* m! C' r& b+ o7 u
printk(KERN_INFO "LED unregister!\n");
3 W- c3 y: g% E; q, M; c}& Q" ^% C* R0 A J, q9 R& d
8 S# \5 c1 w0 q; W
module_init(led_platform_init);/ b- P Y% U3 b' A; r
module_exit(led_platform_exit);
/ |' a+ e8 L2 w# v+ |8 c4 B, Y5 k
MODULE_DESCRIPTION("Led platform driver");
2 k) P+ g+ I! f9 `1 B! TMODULE_AUTHOR("Tronlong");
' Q8 R" W; ]$ g9 v2 ?1 M# w4 Y4 iMODULE_LICENSE("GPL");
5 J) g1 _) |, J- L% u( \. Z8 F+ h. @ ]9 J4 D5 k
|
|