|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 E6 B$ e5 s* n3 ]5 L
#include <linux/init.h>
* F# s% B0 q( Z* ?4 i#include <linux/module.h>
9 V& _0 a2 s$ O* `#include <linux/kernel.h>
6 c6 c9 {4 o+ N" n1 y+ {9 _# @; |#include <linux/types.h> c6 {% Z5 F, {; n5 A
#include <linux/gpio.h>
& r0 D: y8 X( |; b& Y4 w#include <linux/leds.h>: L( s# Q( p% V' ^* L* P2 n
#include <linux/platform_device.h>* Q! S, K) r" z" _0 ?
* U3 D7 a* b' e2 u! K1 r o#include <asm/mach-types.h>/ z3 j/ P( ^( U
#include <asm/mach/arch.h>3 m2 @! S. J% R% y5 F
#include <mach/da8xx.h>
6 M) U( z7 l6 o4 ~#include <mach/mux.h>
% E" t, P2 {& ^" T5 U# q/ U; J( G; C+ ^6 f/ F5 c* ]8 b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 J& L, S# d8 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) @3 ~9 R3 w& t6 w; V2 r% X5 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 I# N V# M" E6 c, |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ G4 U, g# s8 d% C0 n+ \; s
& y3 |, J2 ` z. s/* assign the tl som board LED-GPIOs*/% ?' I; i( b# {: v1 H/ \6 T, `
static const short da850_evm_tl_user_led_pins[] = {* \/ S6 q ~5 n# d! J4 m1 D7 [! \+ t
/* These pins are definition at <mach/mux.h> file */1 D7 p; S$ @! r5 n2 }2 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% L. l/ l7 U& X0 p% |7 q1 s
-1* u+ F8 F2 h/ _4 m! u& g; c" q- j1 i5 B
};
% g+ o, o* Z5 y1 ^9 S0 D) q' ^8 K) S6 C
static struct gpio_led da850_evm_tl_leds[] = {
0 B/ ^0 R7 l: u4 x) ~% C, c9 \ {- n' m. i+ B% m
.active_low = 0,6 S* e3 Y0 p/ q: ]: C. ^
.gpio = DA850_USER_LED0,8 w# Y* X" m+ }: }# t1 v1 f. y
.name = "user_led0",+ D3 ?# i# V' `
.default_trigger = "default-on",
- D" Q; a4 q! S3 P) x },
* _1 _# Q2 J @+ c8 h0 Q {% _" a! \4 m0 ~8 }/ @7 \
.active_low = 0,
# `! `: G" V V5 }$ x4 x .gpio = DA850_USER_LED1,
5 D+ i4 { T. I" v5 w- A .name = "user_led1",
# ~' ~' [/ p( P: Y4 L .default_trigger = "default-on",
4 v% G$ i( H, s6 s* }* b },
, k5 A* E( H4 g3 ^0 y2 o3 d# m9 o {0 b" c3 L6 |$ y2 R
.active_low = 0,$ z, A0 I! Z3 J- h: T7 \" y
.gpio = DA850_USER_LED2,
+ M7 G4 U+ d, ?6 ?, X$ } .name = "user_led2",; i( }& n, r( p
.default_trigger = "default-on",
) e" Z. h' L: B# z1 P3 E8 M' _ },
0 R# H6 Y. S% @2 R; Z9 | {% d; X- ?- ]7 w. ]) c+ m
.active_low = 0,0 Q* U" e, {8 d/ [& v- H
.gpio = DA850_USER_LED3,
5 s% i: ~3 H$ O% D .name = "user_led3",
$ G! C7 {3 _; s9 x" @ .default_trigger = "default-on",% o: [0 p- m4 c3 T
},
9 K9 A+ s1 W, Y5 J};* I# ^* X7 K5 o* ?1 s. o
% F% j5 s/ n' N; R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) E1 K5 D, ]; ~: h& H2 c- _ .leds = da850_evm_tl_leds,, T4 o1 A" }+ f) j* }6 m6 V
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 D# S& H8 @( h# r8 t8 U6 l- I
};4 y; C* p! x) E: h+ ]! x
2 y8 J9 g. @/ N& C: y9 s5 Nstatic void led_dev_release(struct device *dev)% `+ _3 `9 ?$ n- r/ ~* E4 |, v
{
f7 Y$ j5 ~- T: a/ s};8 I. _3 H+ B& z: J- |
" L7 f, ?2 y$ g1 U: `, \
static struct platform_device da850_evm_tl_leds_device = {
4 x9 m5 Y2 ?# ?# a' K; } .name = "leds-gpio", l5 B9 |% z( t0 S) e' E4 H7 z
.id = 1,
. E) ^" F" R2 i, f .dev = {
/ z! X/ d9 R6 u+ L% m; \* N& k" x .platform_data = &da850_evm_tl_leds_pdata,
U, V$ ]& D; E3 ?, b; G6 C2 B .release = led_dev_release,
5 J* f0 a2 \9 T, e1 O0 V5 L x }8 w9 L4 h2 W- s' R( [1 R9 {
};
L6 V! @; S- V8 R+ c1 _2 J3 y
7 j H6 n# w, A& @. I1 u& bstatic int __init led_platform_init(void)8 q, ~; m5 U$ H3 D
{/ s; U2 j; ^* ?' U
int ret;
W; F- v. R" w7 t2 U; \#if 0- o! Z% G5 e( ~& o+ V* {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 @% V0 ]3 ]0 R6 v( h9 u3 t* @ if (ret)
5 C6 C+ |; H! m+ J$ q7 Y0 |2 @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :", L- K, ^& @/ b% M' Y9 Y, O
"%d\n", ret);& Z9 c: n& X8 P" c8 R8 `( c9 r
#endif" c7 F* w+ Q0 V+ [ H
ret = platform_device_register(&da850_evm_tl_leds_device);+ a7 {; O$ c6 O
if (ret)
0 z5 G/ J8 v* L7 p" ? pr_warning("Could not register som GPIO expander LEDS");# w0 X( W; {- ]8 q
else* k0 m. ~4 x; F% I
printk(KERN_INFO "LED register sucessful!\n");' Y2 k" K4 v3 ]" j% s6 Z
# n# t t' g: ~% ^* V' H
return ret;
$ K7 s: r7 @0 K% _, y}
3 h) `/ A7 }( D. \( Y/ C$ L$ r! p) V
static void __exit led_platform_exit(void)' I4 u% h+ h- O) n! N
{
% N+ Q" p4 I' b2 A* `$ O platform_device_unregister(&da850_evm_tl_leds_device);( }' T8 J2 _1 ?6 ]: e5 E0 _
2 ?: p/ C% N3 K& W printk(KERN_INFO "LED unregister!\n");
2 ?' ?# z1 ~, v+ |8 t" X+ l2 u}
5 ~2 u/ }) C$ K2 ~3 W+ Z1 `, ~$ G- w9 X& U
module_init(led_platform_init);5 c, M# d# t0 ^- t# H. c0 l
module_exit(led_platform_exit);
0 w/ K% L! I: G# I" O. E# D
( d( }+ T+ o9 w# F8 ~9 @$ B. cMODULE_DESCRIPTION("Led platform driver");2 j J. c( Z% b' L1 ^1 a% Y- Z
MODULE_AUTHOR("Tronlong");
% f6 G m. w' c8 V" \# wMODULE_LICENSE("GPL");
: g& Z- x3 [* a7 W, }) w0 `' e1 H F) Z" s" A$ m
|
|