|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 E. o( x: L# g6 k# W#include <linux/init.h>; R) `7 `6 A4 ^4 y" [7 K8 K
#include <linux/module.h>0 a% s6 X& \# I/ s. M; t8 e( @
#include <linux/kernel.h>
t0 q( N6 ]/ U! F4 B, M6 v! G1 E#include <linux/types.h>
" E! y) y3 q# r* i7 p#include <linux/gpio.h>
5 r7 I1 b. f' r, d7 g% y/ ]#include <linux/leds.h>
7 B- y" h! q0 l9 o2 Y0 L#include <linux/platform_device.h>
$ L3 b7 c# V# R( n" G
& t5 L4 x: s. y) W0 U5 E#include <asm/mach-types.h>5 y* K: Q4 y+ Q3 k" Y E' |! `
#include <asm/mach/arch.h>
( ], N1 O" ~6 X7 a7 S#include <mach/da8xx.h>1 ?) D2 ~- J9 h. ^! ^5 @7 X* S: c: Z
#include <mach/mux.h>% O8 }1 I$ z ?/ Q* `' {% O" j
& l! Z" p" ^+ B4 [+ U2 V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% `4 X1 O" a) g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 q4 n w% M+ p5 w5 |2 W; r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% G7 l5 t) F, y6 q @0 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ i9 l2 b: ?; q) c; H
5 e+ m2 [' F O* |/* assign the tl som board LED-GPIOs*/
6 J8 c. s8 y7 H. w0 a2 kstatic const short da850_evm_tl_user_led_pins[] = {* x3 j n% B! T5 h0 Z
/* These pins are definition at <mach/mux.h> file */
. ?( b! r/ Y# t6 R* y* H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) J9 E% s8 b, w3 ~
-1
3 w) N& f! T2 R, y+ t9 o};
4 A5 {4 a& B7 B0 X( O
; T. Q8 [; o, U* ustatic struct gpio_led da850_evm_tl_leds[] = {$ I# W; |# ?1 N$ q3 {, }
{$ q" P( w% `0 N* ?5 A3 l! K8 X3 i
.active_low = 0,
9 V4 T+ d$ B4 m/ |$ z+ B .gpio = DA850_USER_LED0,
- u- m/ Z/ o8 q .name = "user_led0",! I6 `0 A, A# _% m
.default_trigger = "default-on",# H! f) g- r+ b* ] u
},; k/ c2 O$ |0 p& c0 H( t% W) S
{
$ x& O* W `; h+ u .active_low = 0,
9 M/ g# Y+ H0 }# k( M .gpio = DA850_USER_LED1,
' G% Y2 A, |& ?6 t: t. d) h* l .name = "user_led1",2 Z: w; h- q/ b) X% k
.default_trigger = "default-on",
, s$ o% f. O" d( Z$ A },5 w- w; B3 X' b' d
{
4 D" ^9 S+ Q+ Z .active_low = 0,
' }2 E1 f( a, o- C .gpio = DA850_USER_LED2,
) s. M% S! C p' W .name = "user_led2"," {) G2 c8 U5 y& V
.default_trigger = "default-on",
' R% F0 m7 t! t+ }$ `+ p7 h7 u5 X' H },
5 H( n8 [" ?( D3 T" ?, c2 C2 c {! C( B1 h" G) Y, ]6 X6 V) E
.active_low = 0,
; T3 r, \% {8 S; N0 ` .gpio = DA850_USER_LED3,
0 k% u8 m* y: T( Q .name = "user_led3",
7 e M$ u& j& a. q: F4 L .default_trigger = "default-on",
! f" \$ V4 w8 Q9 [ },
# L- j6 u# X- F! {5 i- g" D};
$ @6 j! o3 w7 [5 z; X1 ?5 y! V
: D( u( a, v6 z7 q* `1 U/ C1 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 v3 |3 S& G4 I4 m' U0 ?0 a .leds = da850_evm_tl_leds,3 w: m4 t0 A% S* ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ W; g) s* w- x" G3 ~};" i* C+ J% Q/ c6 H
' t+ O; E- y- k; m5 ~% V
static void led_dev_release(struct device *dev)2 k" A4 x3 e |9 l
{, `- p! w. S) l; S
};' F8 Z" k4 k( t; Z) W
8 d# i; g1 b ~0 J8 G
static struct platform_device da850_evm_tl_leds_device = {
# g/ N) S% \) R3 r* o$ @( a- w& x% u .name = "leds-gpio",: c- p( P+ b; C# H4 c& L, \: Q. ^
.id = 1,
4 X' d7 j/ D) J6 F .dev = {$ ]$ B5 y2 K8 k- t, T( [
.platform_data = &da850_evm_tl_leds_pdata," V4 m1 p1 v, f: p( f! w+ c
.release = led_dev_release,
, j3 d( V1 J8 P% w }
: M7 I1 @' F& k4 j4 F E% K1 i' K};4 q: ~( x+ x; B- m j. _9 o7 n
; q3 d5 M6 K1 q
static int __init led_platform_init(void)' S9 U. i6 r" Y# K# B' j, b- z4 _
{# H, o4 ^1 ?5 E, Y; d" l) f( T5 y! l
int ret;7 k2 f% u q/ [7 S. P- x
#if 0* ?7 b) W9 \2 o4 y* |3 Y' P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, c U( M5 l9 D" w/ c if (ret)
* G @5 g* ~$ K- o3 f2 m+ Q7 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 b0 h0 Q- T" `/ X! W# Y0 H "%d\n", ret);* ^2 q4 Z7 R% d$ H' ?# {/ }" j
#endif
; ]) M% z3 W" y6 L2 D2 G" ~. R ret = platform_device_register(&da850_evm_tl_leds_device);
% A* N# b" G y" P$ E if (ret)
5 \: \- @' U6 A* S. C pr_warning("Could not register som GPIO expander LEDS");
+ L3 r9 I7 @$ b. l# I else: z3 o* j! `$ M7 e' K
printk(KERN_INFO "LED register sucessful!\n");
# l- a; Q# A4 e; O
, w5 y+ }0 |0 N return ret;0 s* ]! c* Y4 A
}- o/ o% I. i! ~( R5 i
! `0 S1 p. ]! X3 B& D
static void __exit led_platform_exit(void)/ c0 h( P, H$ p
{/ ^7 R, T0 l7 L
platform_device_unregister(&da850_evm_tl_leds_device);2 r8 I0 ]9 ~( D+ R0 K6 v
. z0 x8 D& `' z" p3 Y7 V
printk(KERN_INFO "LED unregister!\n");# u' W ?$ T; x! J. ]
}+ _/ v+ a+ O0 h5 r P8 ?, m
! B/ L# j G8 \
module_init(led_platform_init);" d0 M! q0 L1 ^0 Z1 P3 `. ]% q. J
module_exit(led_platform_exit);; u, f4 S9 P! w7 ~
9 Q8 ~5 |1 R' \1 v) ] ~1 s) HMODULE_DESCRIPTION("Led platform driver");7 v& J6 c- s# O4 H
MODULE_AUTHOR("Tronlong");% J; M6 S7 A5 i) K, h3 K7 n6 @% ]
MODULE_LICENSE("GPL");* g K# p7 A* y. G5 s
' D9 l5 T+ x' S; t% ^2 l; _' A M
|
|