|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 b2 ?0 ]9 n+ S# |4 J* l#include <linux/init.h>
+ s8 F1 {, z. k' f1 b#include <linux/module.h>2 @' U$ q% [2 s6 H* L8 e
#include <linux/kernel.h>
; I3 M+ I9 s! G6 ~/ O& T#include <linux/types.h>2 k/ f" a/ b' s! d6 P: j
#include <linux/gpio.h>" l( s7 u6 V8 E! q
#include <linux/leds.h>
* M. ~5 K9 U0 m3 u% t& }#include <linux/platform_device.h>: K# [5 {$ L, W4 s. p
4 a O, e+ n9 P) m7 x$ J
#include <asm/mach-types.h>
$ @9 J+ h/ R, h3 P1 v#include <asm/mach/arch.h>
, @( B# u( t" n+ \6 f. B#include <mach/da8xx.h>+ ^) M+ c. L7 f: x
#include <mach/mux.h>) |& B. a, R! M7 k9 ~
8 y, t' E( t5 |& I3 d9 n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 Z# D Y5 W& _5 U1 j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- p' Z8 A- j. `1 m. }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 V7 H& S# x# M0 E8 d8 A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* F* [+ b* _5 Z. i5 `% Z8 I+ u" J3 @+ G
/* assign the tl som board LED-GPIOs*/' _; R k& R# T; ?8 T1 v
static const short da850_evm_tl_user_led_pins[] = {
7 \ ~4 ~( m# f% Q1 R /* These pins are definition at <mach/mux.h> file */7 f: D8 @! B+ h1 c4 X% Z, g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 M* I4 n# y3 z' K
-14 T' f- o8 f1 g3 x4 C
};- `, v1 n f* V, A& E! f- E+ T6 d
% L6 y6 ~* ?9 kstatic struct gpio_led da850_evm_tl_leds[] = {
% j4 O4 g# F# F. q' e& y; ~- P7 n1 b {
$ G% R3 ? P% x8 Q0 H .active_low = 0,0 E$ x/ I- j1 O4 R
.gpio = DA850_USER_LED0,
6 _. n; Y+ [" R5 _, [1 s. G .name = "user_led0",
( l; Y" s' d1 ^ a .default_trigger = "default-on",
. x- b0 g% d* E- h& @/ C },3 y2 z7 {7 c( E$ Y2 R
{0 |* o) _! y+ C2 }) b& u$ M/ I
.active_low = 0,
9 o( `- _- ?. o3 a* l .gpio = DA850_USER_LED1,
3 R: f5 t! ~6 g9 N( u. M! B .name = "user_led1",
6 s+ U9 a0 l* n3 m6 \% k .default_trigger = "default-on",
3 ?4 t+ Q" d( b },
7 z4 J. }4 X. R/ I ]1 z" u2 w: H {" m6 `( Q& f7 l
.active_low = 0,
& C1 v" }; }5 [5 |: V) a2 Q .gpio = DA850_USER_LED2,
c; s+ n+ a8 ^0 d1 D* _2 ^+ e: } .name = "user_led2",5 \4 x6 w9 n& w5 | ~
.default_trigger = "default-on",
" i, D+ b' \ A7 L; n },
9 Q; K: O) t% o* J {6 |5 N+ n8 U4 P- r1 H& M- k5 D1 T
.active_low = 0,
; w& \7 J# M/ c2 J9 @6 k' J# Q .gpio = DA850_USER_LED3,
2 T- x; O9 _# R. O .name = "user_led3",
7 `3 z1 X7 E$ Y+ k .default_trigger = "default-on",$ J3 Q, J- b; m% |
},
3 j6 `/ U# ~8 x0 p, w' w};8 ?5 m) G) c3 I/ I9 p7 c8 u
) ~0 |( e6 D; w! I5 y* Z% L" Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 s( \$ V( I$ b' M .leds = da850_evm_tl_leds,
0 w9 y9 n* j y8 g) m# z. \4 c# F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ K7 D7 N$ v6 ] B, x6 q};& E* z3 v/ E' N2 E j) |( [8 S
/ N l: W& f# C: O* R- c7 ~. |static void led_dev_release(struct device *dev)* B( G* e. z- [2 g _+ k. v) A
{
) H: m9 t3 |9 q};
/ @. I; H- R* {, O l Q2 u
/ p \8 G5 S& ~" Ustatic struct platform_device da850_evm_tl_leds_device = {4 O1 R: U( V; P0 h
.name = "leds-gpio",+ Y& {* O$ `# y' e
.id = 1,
( K( b' b7 `1 T" X .dev = {
G/ N; Z9 ~* d* O9 Q .platform_data = &da850_evm_tl_leds_pdata,6 [4 F: O$ A6 e
.release = led_dev_release,
/ d8 m( r7 h( s7 ]/ [7 k }3 g9 ]: O$ K5 F
};9 ]. E1 e( C; e$ J2 v
' }, p% y L( s5 k4 l- l
static int __init led_platform_init(void)/ H& v$ R( A6 t
{
8 e& Z4 w5 K6 ~. k int ret;
/ B, B# ]) c2 u& x9 u2 D( [% \' W#if 0
) K, l1 e5 S* g9 U! C& o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 _# j* T6 E0 Y8 |
if (ret): [" _8 U& K. i( }+ r
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; I/ \2 Y6 S( Z4 B9 n( K9 k "%d\n", ret);
3 Q1 r6 U6 H5 U+ H! p: r5 {#endif* v5 I+ v. F: V1 X
ret = platform_device_register(&da850_evm_tl_leds_device);1 i% V0 @3 O! a2 Z! k
if (ret)
( n0 `" |# c, C0 [& M) n2 t pr_warning("Could not register som GPIO expander LEDS");
) N5 H, c8 z' r6 v% ^ else6 y4 j; h3 G C
printk(KERN_INFO "LED register sucessful!\n");6 n% n# j0 L( z% g$ e9 ^
, m9 ?7 `) j3 l- y. {
return ret;
+ o- b G5 a: e8 S}
- H% _4 @- V6 I* E$ n+ g
8 Q) j, g7 x; t& }! z4 n- Zstatic void __exit led_platform_exit(void)
. [1 Q9 v! d% N2 P4 z{5 H8 w: E! j) V: D Y
platform_device_unregister(&da850_evm_tl_leds_device);
. b9 g8 R5 A4 \1 c5 K: o0 h0 B8 R, [
: N1 G# o( b g& b8 W& Z, X printk(KERN_INFO "LED unregister!\n");
7 @7 m6 ^( _8 o, H0 t/ K}7 U' Q; M' l4 b" d! l/ _7 G4 o" G
9 m' l1 }: ^4 r) u" J
module_init(led_platform_init);7 m2 J3 z" w2 ]6 D. m: b& f2 \
module_exit(led_platform_exit);
3 I) M% F }# Z! Y6 v* E2 l1 z4 i. [
MODULE_DESCRIPTION("Led platform driver");
* M. B ~9 L/ d$ A' {MODULE_AUTHOR("Tronlong");
7 k7 `8 q3 f7 j. `: m3 Z; cMODULE_LICENSE("GPL");
' f G8 X* s7 t" h6 B1 u3 J' ]2 r2 P/ O7 W# Y1 t
|
|