|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- }# f% c6 }& P( ]#include <linux/init.h>; O7 d1 m# [( o% i& D, ?5 N
#include <linux/module.h>* t- E* B8 z4 w3 j) T( p" q
#include <linux/kernel.h>. g, i; u: d7 Y& V
#include <linux/types.h>, F1 c" A3 ~: a( }% z" w
#include <linux/gpio.h>
/ g8 d+ {# _. H2 w+ Z#include <linux/leds.h>
1 |4 S& P \$ h# `$ X* w#include <linux/platform_device.h>
& ^& _" b5 G& _' G# @ S# c% y1 J8 J) K% _; R! N, b' n: p
#include <asm/mach-types.h>
1 {% b) W, V# s" y& o) Q' N" S* U#include <asm/mach/arch.h>) E* z {1 k4 t5 W+ \1 ?: L9 _
#include <mach/da8xx.h>& ^+ g. v: p% f8 S6 [6 B; N
#include <mach/mux.h>
8 t" r2 t$ ~- ^3 m: E% C4 d* C
6 L& ?" l; l6 C2 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( K, ]/ v( Z4 [/ Y! N) w/ o a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 ~7 z, O, a8 V/ _' ?! e" |" p8 H0 z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* p- i1 L) H! T2 v( O, m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, X1 s9 m+ q( R$ ~; r
k+ u5 C/ c6 n/ o, P+ d: }1 i* K/* assign the tl som board LED-GPIOs*/6 X9 M! P g4 n$ p
static const short da850_evm_tl_user_led_pins[] = {
, H3 ^, d) F2 @0 u( z /* These pins are definition at <mach/mux.h> file */
2 U* m2 _" k2 ~* m1 ?1 W9 [ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: j* k, Z% L( Y1 ?" d$ T% L( [ -1
" f* {0 ^2 m5 B$ \};
2 B) k4 j# w8 K& V% \. C7 h! v. d) Q
static struct gpio_led da850_evm_tl_leds[] = {9 M5 A/ o* c! Q- i' t
{$ w+ y' _4 H7 j$ _% Y" X
.active_low = 0," k+ w! I2 D% \: y5 }' ^
.gpio = DA850_USER_LED0,4 l& |# K, S; h$ d3 ~6 ^" X
.name = "user_led0",
- t0 s3 X1 W3 m3 A) b .default_trigger = "default-on",
( U% i2 I5 O3 o' H$ x3 x5 @2 [ },
4 j. _; Y7 j* a4 | {
I9 c+ |4 `8 ~, X .active_low = 0,& o1 Q9 e: z" {1 E# i
.gpio = DA850_USER_LED1,5 V( v2 g1 j C6 I8 M0 D
.name = "user_led1",
# P. e2 q) |, @ .default_trigger = "default-on",6 h8 A& g, Q3 ^0 |* U- |# k
},' s8 Z6 X5 B4 i/ t4 G
{$ y- J0 T7 s, o1 u( ^
.active_low = 0,( r& c8 ^0 D2 g7 u9 b4 Q' |# d% z
.gpio = DA850_USER_LED2,
' Q# W; A' _" x* z( J .name = "user_led2",
& ]% b6 o+ S: P# x0 W& f .default_trigger = "default-on",/ b) L( R& {, S U5 R( C. Z
},
; ^2 b4 j8 K+ \) d3 S2 d; L: H {
, j' \5 s5 _6 V% g3 F, ` .active_low = 0,
: l1 X! p3 N% c .gpio = DA850_USER_LED3,
4 Z) }3 _- I9 x" Q .name = "user_led3",
& V9 s7 T+ M" c9 M, {2 u* R4 Q; m .default_trigger = "default-on",
1 {" V" O8 \ i },' `: t2 E1 e `1 L- a& V( j3 W5 U
};- ?, f9 L9 j% ]# g% P
- a4 ?( c r( `" L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" Z. f2 Q9 [; b( b; e |$ H
.leds = da850_evm_tl_leds,
" ~6 D$ V# x* j. b3 I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- E; V9 I) v1 g1 P5 T5 Z};3 i% R3 q* O1 a+ u: b4 j: @
v8 j8 _/ F8 k& V1 ^4 |: B
static void led_dev_release(struct device *dev)* S0 G/ z+ q% k8 N( c+ m. L! R" V
{8 J' i, N$ A. z! `
};
' h6 v7 c) o* N$ E4 r( k6 O6 z4 k w$ V
static struct platform_device da850_evm_tl_leds_device = {0 t$ V0 ~6 |8 b8 {1 L
.name = "leds-gpio",1 v7 f/ O4 C( U7 w
.id = 1,
4 Y+ @1 `9 \4 G# x .dev = {4 \$ l% |6 l, C7 Q$ H
.platform_data = &da850_evm_tl_leds_pdata,
/ g# r9 M7 U9 c9 I6 s& | .release = led_dev_release,. R$ {& r* |9 M; `! h' L
}/ t1 D2 o6 e- [) I! h
};# [, ]6 b; Y D$ Y* G/ x
( S# @& S7 P1 G2 N5 a! j
static int __init led_platform_init(void)+ u# U6 [: U0 d* W
{- j* x. T" N2 j1 q3 j& a
int ret;( ?6 O$ M/ o- {( o3 X. ]. `
#if 0
- x) O! p; Y) y$ U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% y5 O1 U! Y$ n Y. ^; a
if (ret)
" o0 Q0 m* S$ Q' Q5 B. y0 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; T" Z' c7 x/ T6 d0 |/ S; w v( |
"%d\n", ret);
8 M& S V; f$ `3 F$ c9 z1 q- v! @#endif
& v% J9 s; j# g ret = platform_device_register(&da850_evm_tl_leds_device);- V8 i& i' J5 w: `3 B: E
if (ret)
1 L+ x4 _1 O2 u g pr_warning("Could not register som GPIO expander LEDS");
$ b% j6 W, C1 e" y8 ?! P else7 K1 i2 F; k4 I: Q4 {- q4 u
printk(KERN_INFO "LED register sucessful!\n");
% a k: q( t% }- U6 |" N3 `$ v- \- B8 Q5 k1 a+ F. d/ X
return ret;
: b- W: M, x$ n6 H7 J* i/ e}2 H p; Z" G9 M7 f$ Z1 O
' y4 z) ?# v6 R( c, G- tstatic void __exit led_platform_exit(void)
, Q! P6 R: v1 Y0 C{1 E2 H# H2 A' E' {6 A
platform_device_unregister(&da850_evm_tl_leds_device);
2 r* C# A! l; a! a" N; o: ?9 E# ^/ p8 [6 z) B! s% G: u2 n* @% ]
printk(KERN_INFO "LED unregister!\n");3 Y" P: i# D( a
}
) w. D k* t" w- i, F8 J8 s- x `! b0 r& W7 K
module_init(led_platform_init);8 j: M, P3 C5 F# ~& u }' r5 c
module_exit(led_platform_exit);
3 r! l% c6 m# ]$ |! F) |6 c* h" `; R$ A: p b. u+ k; B
MODULE_DESCRIPTION("Led platform driver");
# [& |& U/ E8 z& p3 O) eMODULE_AUTHOR("Tronlong");1 n1 w/ G# e3 X) _
MODULE_LICENSE("GPL");
: t) S+ C0 }. V+ V
H% y& B( j, k- j( m |
|