|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 E9 Z8 }/ ]& X#include <linux/init.h>) v# p7 `6 _8 t( f: t; O. n
#include <linux/module.h>
: h9 q8 Y- p9 ^#include <linux/kernel.h>8 t, _2 C" n, _6 C% Z2 ?% p
#include <linux/types.h>
. ^9 Q7 B( C% v: T( y2 J#include <linux/gpio.h>2 y& o1 L N( h; |( J3 b
#include <linux/leds.h>
6 K' ?( |+ `! e3 r2 }! G& \- ?( N#include <linux/platform_device.h>* x- m9 n% z+ Q
4 _2 ]1 _2 N$ u8 s {/ A; k' l) R
#include <asm/mach-types.h>: t( T3 x# M2 a3 E9 y4 o* Y: w
#include <asm/mach/arch.h>( W8 p9 e* A- b2 O
#include <mach/da8xx.h>
2 f( ]8 {4 `8 Y$ b#include <mach/mux.h>; ]3 M- ^/ H* X# g
0 ?, ]6 r- a* g D0 h! B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- X* h, L8 n3 i- @/ T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; [! P# @7 n. ?$ y7 @3 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% g1 ^- P" v6 a' {7 m4 a. r a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! }1 E6 ^$ x9 D) u) T6 I
: Z* W F5 w9 J6 W2 ]3 k6 p1 X) Z/* assign the tl som board LED-GPIOs*/
4 r8 W' e! I1 U& y6 {. Hstatic const short da850_evm_tl_user_led_pins[] = {& f5 m: Q- p# X- V9 y
/* These pins are definition at <mach/mux.h> file */
4 `1 |) W- a4 M, G7 A4 w- N% ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# P6 v0 Q6 O4 _3 d3 G5 f- J -1
* a: H: k. B2 [6 o7 a6 p# \9 O};4 H+ z3 ?4 h$ e! b
* {* |; Y- h# W- @
static struct gpio_led da850_evm_tl_leds[] = {
1 I, J0 z) j* H! }- S7 a0 Z6 @: l {8 Y M& ~+ U* n+ S) u
.active_low = 0,
: n$ h- q% s. H) J" { .gpio = DA850_USER_LED0,
0 {' R+ Z, i; S% j .name = "user_led0",
: M: m0 f1 n( ^$ O .default_trigger = "default-on",
' g( c, M% K. D' ], v; X# p },
) P' y, P0 F3 v: [ {
: O* }9 F9 G5 u- T .active_low = 0, T9 q/ O# J4 k" e2 I6 U
.gpio = DA850_USER_LED1,& x6 [! \, n H9 C: c# e
.name = "user_led1",1 V# R7 Z7 m; x3 t
.default_trigger = "default-on",. c% M5 N0 \* x2 e. y0 t m
},
3 _6 `( v7 C0 a s {
: n+ n: |8 F3 n( s2 e .active_low = 0,
" @# m0 C& L" c .gpio = DA850_USER_LED2," b( u+ m5 ?3 t6 E4 Y/ W
.name = "user_led2",
2 z Z4 Y1 j p) E1 o* w .default_trigger = "default-on",2 K$ U/ U$ Y+ ]! ]- U- X% M% h
},
; J7 c3 P& G4 f" A, E* o {
7 R) c$ K( @7 \" R- L2 I .active_low = 0,
3 H$ F/ ^. d; s3 T( H7 \; g$ l# H .gpio = DA850_USER_LED3,7 b! E$ |: ?! R; o9 f2 K
.name = "user_led3",8 [( G. j5 v4 \" O4 O, Z3 u
.default_trigger = "default-on",
. l1 i; R1 @( K },
4 r: Q! d1 i8 |! W9 X};) o+ Q8 K+ ]% G) U3 \& F
, {4 A9 Z U) m6 O) n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 c; @+ G: P2 \. L0 u .leds = da850_evm_tl_leds,
. n. u, F5 y& @# h) V% \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; k; b2 }3 B* }# O& M8 ~1 F p};
8 f! V) f+ s) l+ Y0 z/ _% P
0 e9 M6 b% y0 W7 i) L* ustatic void led_dev_release(struct device *dev)# P# i" @) B( ^% M$ b) Y% h6 o9 T4 J1 R
{
8 ^2 D4 Q3 A# F0 N};
- G5 O, E& W7 s; v- ^6 w; D; Z- m, r" I' ]
static struct platform_device da850_evm_tl_leds_device = {2 S. m2 p6 I: l0 C: q! s. h6 p
.name = "leds-gpio",8 W# w9 I; Y& Q' A; H; t" r- F$ H. X
.id = 1,
* S6 J- q. N' U! m1 Q/ O .dev = {5 y- R& w6 B1 t* y
.platform_data = &da850_evm_tl_leds_pdata,
1 V3 N& s% N9 g3 e" ]- E+ c! j. k .release = led_dev_release,/ | E. E/ r: h5 V# g/ C2 f
}
$ e, O! q6 M9 P% n};
/ T' q# p9 ?* g/ D' I; l8 C! r* O+ l, B; ?" S# L P' R5 J, D
static int __init led_platform_init(void): K0 {5 K" r: }& [
{' ?0 i, A; c$ r; M# ~
int ret;
+ R) y. u: M, |1 n+ S5 O#if 0- ^+ Y) m# |9 s6 m3 d6 C# D- B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( F- v2 V b0 o" Y
if (ret)
( h K0 K7 z3 Z9 E$ ~) | pr_warning("da850_evm_tl_leds_init : User LED mux failed :" T( V- ~ I5 ]1 F* }! C
"%d\n", ret);
$ I X4 S* t# U( f* f% E) k#endif
- x# i1 C5 N- t ret = platform_device_register(&da850_evm_tl_leds_device);
! S8 u1 t4 X: d3 M, I if (ret)" g, `- T8 O. g, C
pr_warning("Could not register som GPIO expander LEDS");
- s4 l+ \( e q7 R% C* a) ^" V else( _$ T& B- N/ x7 x& J; R' {/ n7 c
printk(KERN_INFO "LED register sucessful!\n");
, a8 k- O/ U: A" M4 Z2 x# \. }
return ret;& p2 z) Y6 Q# L8 g
}$ ^, N2 t7 h3 ?$ k, C
' Y4 S' G" f& w9 j0 r
static void __exit led_platform_exit(void)
% ]$ K) k1 c/ b. w) X# ], L4 n{
5 w' L/ @% _6 F8 Y# v platform_device_unregister(&da850_evm_tl_leds_device);
( I5 ?/ N, h& Q3 Y! ]. t. Z. x6 k4 r6 M3 h* R
printk(KERN_INFO "LED unregister!\n");
, {* c# H/ z$ K. Q# L$ M9 Z. ^5 M. g}
& q; a2 C+ `* n# ?( U5 `- N+ u
: v9 F8 M+ M# v3 z/ G' i7 m4 Hmodule_init(led_platform_init);
* s5 y# l+ Z! I% T4 O. f! Qmodule_exit(led_platform_exit);
" Y1 o& X& j4 Q; F
) L9 t6 U0 A: r* y- rMODULE_DESCRIPTION("Led platform driver");
0 L. u' U5 ]7 l( e5 ? [0 J. P' P$ v. DMODULE_AUTHOR("Tronlong");
! `# p1 Q- _2 p# qMODULE_LICENSE("GPL");% X: t/ y$ b% z! P, O, ~
+ |* ?1 e. ~7 P1 ?2 S* V9 a/ P# {, Q6 z |
|