|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. y: x" s/ D6 R( ]; P4 I/ @
#include <linux/init.h>& y! G* w$ g0 b1 ~, K
#include <linux/module.h>
2 _. X2 A, n' ^" _1 _#include <linux/kernel.h>
0 R4 _6 R1 B6 q) z; N#include <linux/types.h>9 ~9 a& A" C; j* }7 g3 ~9 J
#include <linux/gpio.h>1 N, F% {5 J3 c, g* w% e9 y
#include <linux/leds.h>0 G1 r0 Y8 s: Y! v
#include <linux/platform_device.h>& o; w2 \! {+ X3 }* r
$ a$ l# r7 O0 A# f- \% c
#include <asm/mach-types.h>$ x8 {8 V" V: [9 w
#include <asm/mach/arch.h>. f$ H3 l+ ?* Y9 S" M' L
#include <mach/da8xx.h>
5 V J1 C' {1 ^/ |0 U# z% L1 X#include <mach/mux.h>; I7 `) i/ D: S, J+ F) j
6 Z1 ^: V9 h/ _5 R- ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 x" R7 F8 [% R3 H0 W* F+ n/ ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ N5 ]( C3 q8 P' S( v6 @! f( X% }0 I2 U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 [. D, x* r; Z" e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" \5 l X2 W [5 b. T4 N
$ L8 p/ j, |. K* T( j }! o/* assign the tl som board LED-GPIOs*/: U# n! B. M8 A, T' k5 X
static const short da850_evm_tl_user_led_pins[] = {
, k, p0 T$ @! v3 i8 @' f) K /* These pins are definition at <mach/mux.h> file */
- w* L1 ?: j7 \0 e& ~' j) y4 h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 m9 i$ b f r' x& b- M -1
$ C4 \+ y6 Z* H9 C};+ g$ X# x& j7 V
( e) [9 @. b5 ostatic struct gpio_led da850_evm_tl_leds[] = {+ [2 P) v+ E' P! P$ T
{
# z0 @" X9 b8 a+ N& @ .active_low = 0,8 H s& ?4 u$ K) j- j& B- ^
.gpio = DA850_USER_LED0," n2 Z8 B8 i- j# [! m5 B3 h
.name = "user_led0",6 J: |& n1 O# Y8 P
.default_trigger = "default-on", k; a2 n& b' R
},+ G# s3 o' V0 {7 K$ l
{% z U$ F1 B, m
.active_low = 0,% u* ?" E0 @1 z- x5 E: A2 \! h
.gpio = DA850_USER_LED1,% |) Z1 h- J9 v5 S
.name = "user_led1",
) E4 H# |% K* K( N .default_trigger = "default-on", w, L5 Y: x; Q; s
},
2 e) y0 C# A- y% z {
7 W9 Q/ v9 Y, `. b8 O8 Y .active_low = 0,0 }: |' @ }8 T0 l
.gpio = DA850_USER_LED2,
7 e6 ~, u/ R' G' j; i .name = "user_led2",
1 a/ c+ G8 ]- |9 N$ W# h .default_trigger = "default-on",% |( v( m5 ~% E9 i- S5 a- w/ T2 W
},
) k0 D5 l7 w* C& K, b7 z; A {, ]' `; ~% F9 ]. | f
.active_low = 0,* F. x, p; u C8 \) E% ?
.gpio = DA850_USER_LED3,, ^# j2 o% Q9 b+ |6 R
.name = "user_led3",
3 }3 {$ m) F3 a# Q, r .default_trigger = "default-on",& u& m' X. ^: M) |
},7 D8 ^% T$ g6 U9 B
};( W! K& ?' r a$ X+ T
( X4 S8 V, e h" ?7 A+ Z2 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& j2 u' z5 r& |0 U .leds = da850_evm_tl_leds,
! j' I- P9 {. ~, l, \# h: z+ A4 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 y4 |* S& D" b) `};
- _+ o2 I& x$ ~
' B' W: ~( @% c7 i+ m+ jstatic void led_dev_release(struct device *dev)% B/ X e& k' H/ v8 k( {
{
3 u+ o0 F! ]* U+ \) v};: N: t( c b/ S \' U6 _
1 y: `1 @8 s3 C1 Q* H8 E
static struct platform_device da850_evm_tl_leds_device = {$ M$ f( N: r1 N" S4 h
.name = "leds-gpio",
* Y X4 X6 \/ L! \. a- } .id = 1,7 h3 n* \3 L" T, l, y+ N! Y
.dev = {0 J/ U& h* V' U) v/ u
.platform_data = &da850_evm_tl_leds_pdata,, j/ e2 n% y: W, s
.release = led_dev_release,
9 Q% o3 T4 Z1 z2 e1 r% ~ }
, S r+ s7 J3 b2 i};
) a, u7 _4 w/ B. C9 P
% R+ D) l/ R% b$ @static int __init led_platform_init(void)
7 o& m( \+ u$ T{8 y1 K! S& G; C! D" m8 N! R
int ret;
3 r* ?7 r6 Q* b! F#if 0
! \ O9 `. k* t2 V9 K% C/ _ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* @- \1 P0 b6 g9 T, P. [- J
if (ret)3 y, D; L ]3 B6 P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" {# L V$ K7 [ "%d\n", ret);) F7 a3 `) g4 B5 W
#endif
, ^. T5 O$ `2 y) a9 c ret = platform_device_register(&da850_evm_tl_leds_device);
' N* s2 Q% P& t/ W6 J; _ if (ret)
T( i3 b6 W! \ pr_warning("Could not register som GPIO expander LEDS");
Z- s# D o; p5 T7 B else5 L {8 s, \+ |: u8 K
printk(KERN_INFO "LED register sucessful!\n");
6 z2 o0 B: q% b: T
/ I ?) x, i0 A/ J. E9 |# w return ret;
" z7 L b; f N+ H, m/ b}) @; S3 W3 T: b) ~ u9 f
7 r+ \& X, j! G, {
static void __exit led_platform_exit(void)
% h2 J% V0 g/ O9 m9 V9 s{! R! F; a. K6 W/ a% }
platform_device_unregister(&da850_evm_tl_leds_device);
" w& t I4 g4 {- ^0 C6 x/ J- @
& b- t) K6 P+ F4 E: F& K printk(KERN_INFO "LED unregister!\n");3 ]3 ^$ a2 E+ X$ [7 S) N) m
}% z( P: `: Z# c
0 V2 P6 J; x' c* W8 x( o' N1 Q0 f! Vmodule_init(led_platform_init); n$ V; D! P' z9 l
module_exit(led_platform_exit);! E0 V+ Z- O+ j) R7 b9 K$ m
9 X6 \: Y' L0 @) |4 [6 }- r1 tMODULE_DESCRIPTION("Led platform driver");
& d1 [0 b. U& SMODULE_AUTHOR("Tronlong");6 T* J: Q$ B3 J" \3 o8 F% c$ P2 l
MODULE_LICENSE("GPL");) O; n6 W& C0 o
* }2 P% n$ G9 X( V. ]! j- M, y
|
|