|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ N0 a) [/ [/ C) G. k' ?, `" Q
#include <linux/init.h>8 G9 W$ {' K) W% W. M3 O. y
#include <linux/module.h>" r9 K; k. k% I) @! V& m' |
#include <linux/kernel.h>+ f2 j! k* m7 F ~
#include <linux/types.h>
/ \+ g! A9 c. a5 k8 }2 N#include <linux/gpio.h>
. X5 z5 T* I1 n; F4 m#include <linux/leds.h>
2 L8 P* x0 G: t6 Z#include <linux/platform_device.h> |2 }: r' B7 m+ q! Y Y+ ^
" X) }: j2 {1 o: K3 b5 p
#include <asm/mach-types.h>5 O1 o. S) w1 ~- l8 ?( @& N
#include <asm/mach/arch.h>
% B" Q. L; Z/ v6 ], f5 m" Y! w#include <mach/da8xx.h>: B3 u! f) ^) K% p& }
#include <mach/mux.h>
0 L K4 n& M$ A J& P6 i9 f4 L2 \/ h+ a2 J0 e( X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 f. A& T- T' F! O# {0 t8 T- I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% t: n& X) m4 Z( l" _5 P6 |, P#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' u) {6 H W; R7 K- p% n3 W3 v; `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ p3 @& L8 Z% B% W* Q/ R
/ i) u+ @5 O0 s m7 f/* assign the tl som board LED-GPIOs*/
% R% K. a9 _, e" kstatic const short da850_evm_tl_user_led_pins[] = {
6 [! b; d9 k0 y+ r3 `) o /* These pins are definition at <mach/mux.h> file */
' |1 B: W% a+ U; t- |# c ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- a! i" P1 Q4 X" ]9 U -17 ~- c3 V/ l9 T- i8 X
};
1 v( D- ?4 L% D. f$ h5 N, ^& J
5 P3 P& ~. n% }/ G( _static struct gpio_led da850_evm_tl_leds[] = {: [, l) d; V2 l; U
{1 v; b& ]. ?, @; Z. |$ _, x& r5 U
.active_low = 0,
7 w' g7 }3 w& P/ J" w6 @ .gpio = DA850_USER_LED0,
) ~9 O3 W. a) V3 n .name = "user_led0",
( i- Z# }, `; \0 u) R. ^/ [ .default_trigger = "default-on",9 B9 e% Y( w, E, c$ R) Z& A
},, ?( s# H' b3 C7 C4 W& ^9 t- v
{# `# R6 I) k; V& w
.active_low = 0,
, s) P* q8 _6 W$ z7 t .gpio = DA850_USER_LED1,
% b6 m L; \ n$ s .name = "user_led1",
. w+ s" z( i& |3 ~5 ~7 C .default_trigger = "default-on",
; u+ y. i' L! h) ` },
( q0 L$ V" v G: v {
/ L$ {6 q! h9 C .active_low = 0,! R) m& J Y1 Q% F" W. n
.gpio = DA850_USER_LED2,- E- p# W9 _% Y8 K$ T
.name = "user_led2",
6 D+ X; P! }$ V% {/ m( H5 e .default_trigger = "default-on",
z6 M0 i- A2 [* t1 e },
7 q K0 t; J- L+ j+ @2 C8 B2 N0 _ {
6 Z7 y0 E: n' y9 Q1 {6 w! ^8 o .active_low = 0,
! D8 w; y+ I9 A. ~- @; _ .gpio = DA850_USER_LED3,
8 |, X4 k& ]- X( Z: }" c .name = "user_led3",
: M3 U0 _9 e. c, K7 o .default_trigger = "default-on",
$ _9 \: J5 R4 X2 N/ a+ N9 G },. y/ \7 v0 b0 _- m# i- X
};
2 M6 D. v- O/ B
5 x ~- t( T3 lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 b, D4 c; z- o; d) U+ }6 \" L% m0 C .leds = da850_evm_tl_leds,
9 W5 V6 ?2 j0 t8 v, U* y. R- z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 b: y, h5 q& D, Q" p4 y4 a' o& c
};5 [, }! i" `; Z& Z, ~
+ c2 f9 m( T; Z5 a- Tstatic void led_dev_release(struct device *dev) G- V/ c8 O! e$ e$ V8 \3 h# E
{
& E+ X9 ]/ E: b1 Z9 B i};
# l' W: e# ]1 x) Z- Y& L& D2 [9 b+ f8 T7 h
static struct platform_device da850_evm_tl_leds_device = {* M* g9 N# E- P2 W: R8 i9 i
.name = "leds-gpio",' h3 E1 [# m9 W& `
.id = 1,% r. ?: [) X2 C, b7 B8 a) A
.dev = {
: o% A% g+ x6 A5 m) |+ H .platform_data = &da850_evm_tl_leds_pdata,
z/ E, y% |* ]: r .release = led_dev_release,# { C' F( Q# S1 W
}
1 Q, l: h: _5 w) i};
& d5 L0 f4 E* x9 O! ?, v. {3 I/ f8 H1 y2 D9 p
static int __init led_platform_init(void)3 b6 X4 ^$ f7 {5 F4 F5 }5 I- ~0 j6 _
{
. M6 v- k f. P4 s/ b/ ` int ret;2 b$ A& r3 S/ d$ h4 b$ U" P; T- U
#if 0
+ @! l! v- b# z! m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! h) x( i) o2 ^ g
if (ret)
& S6 v6 P) R4 i6 N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" a& K, T# N/ h7 T
"%d\n", ret);1 z/ Q/ E# Q8 C+ h6 E+ o2 g4 d/ \
#endif- w, F9 w% h/ Y" t$ P6 c. l7 i* ^
ret = platform_device_register(&da850_evm_tl_leds_device);
6 E" D! m0 Z4 T* Q* G% X if (ret)
# R& n# |/ a& i7 X pr_warning("Could not register som GPIO expander LEDS");
7 G, \- ~# J3 R# X' X6 K else
# ~2 t/ |: ?( G" N+ d& C0 H( e printk(KERN_INFO "LED register sucessful!\n");- E. \$ ^# \* p6 E0 l
7 V1 w2 C: ~9 N0 C0 q
return ret;
/ f. _4 s9 r/ p}
) y# ~! n" t" n9 |7 q9 n' z5 c: ^/ _% d& ~
static void __exit led_platform_exit(void); p2 P& R: a. A& ?
{
0 m4 }! x6 k) @( d0 j: p platform_device_unregister(&da850_evm_tl_leds_device);$ \4 N; T' _, K) v+ Z' w
& e% Y( M8 i, X' @
printk(KERN_INFO "LED unregister!\n");
) l% s# V/ c. D+ l}
7 ]" Z6 p; d6 ?# a& [! N& @! Z+ M
" c! V3 O2 t; r j6 w& U4 gmodule_init(led_platform_init);- q3 x% L% \8 G& } e" \( _
module_exit(led_platform_exit);
1 v7 h P: T, V1 C- Q) U$ r! ?2 X( a5 G: s" w% o; u; i! t- \2 Y, R
MODULE_DESCRIPTION("Led platform driver");) m. @' F/ N7 k. w& Q% z
MODULE_AUTHOR("Tronlong");2 E# {0 b# b E# g m3 Q
MODULE_LICENSE("GPL");6 ^" A8 `+ |7 t
. [ _2 Z. V4 |7 n |
|