|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; q! U+ v1 \! ~2 T5 O+ {: U: q
#include <linux/init.h>8 \3 X% h1 ?/ M5 L6 m k5 D4 K' [
#include <linux/module.h>5 r2 k7 ~* Y4 j: J) O- J
#include <linux/kernel.h>' g0 @6 B& Y; {
#include <linux/types.h>2 ]$ a9 f% A% x2 V5 i" }/ Q. ~
#include <linux/gpio.h>
( y0 }2 V' y9 h4 \( a& f% u#include <linux/leds.h> X6 n' X- H/ y/ M7 O5 F7 Z
#include <linux/platform_device.h>
( M1 q+ P% M, [/ S: T
' i2 J, _; O- h1 k/ N5 X#include <asm/mach-types.h>3 e5 E( h) ]) B6 z2 x% S8 ^% W
#include <asm/mach/arch.h>
, ^! G, \7 c7 |5 B% h, C#include <mach/da8xx.h>; k9 H) N' ^; U* E; K7 t
#include <mach/mux.h>' }- g Z4 H& D7 `# O: i" L8 D
% f1 U4 p/ k% H' R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ R# H* G F- z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, v9 e3 u' L5 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 @$ r! h3 t; v. _1 F9 p* n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& m% Q' ]6 C# E
% h8 {: K/ S, W& P8 V* p* j% G/* assign the tl som board LED-GPIOs*/
# d# K9 D8 N! j: I1 b; C, Mstatic const short da850_evm_tl_user_led_pins[] = {. D( {% B% i- _' b9 B2 a' Y" o
/* These pins are definition at <mach/mux.h> file */- @5 x% Z. D! P* v+ g+ q0 i
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ f& u6 }9 p: z2 n, V- ^, V: v
-1
( {+ b" S5 j! u! Y S) ~};! O, r6 p) c" a( h3 i/ O2 C& m- ^
" `7 g4 l3 p! s# t, Y6 b$ A* J! _static struct gpio_led da850_evm_tl_leds[] = {
7 ~& q6 m9 g3 T {
; I% C4 O7 l1 _4 o* J: d .active_low = 0,1 h6 u- [; S4 e" u( F$ ]9 a
.gpio = DA850_USER_LED0,
/ m6 C H- d9 } J5 N .name = "user_led0",) I# L$ _# M8 h, c# n- k
.default_trigger = "default-on",) Z$ Q; i$ j. U# S2 A, D
},2 a3 G! g. j5 n( |, `* a
{- B; s0 N8 n6 e/ w6 x$ i7 }6 D" Z
.active_low = 0,- ]5 X7 W" }, a
.gpio = DA850_USER_LED1,
" D0 D x6 K2 G+ ?; k/ \ .name = "user_led1",: a, u% h+ v( U- l/ ~
.default_trigger = "default-on",; P+ o# g6 e2 P* U* u; R
},/ Z U2 B) `, t0 C
{
; ?) f+ V/ V" Q4 b .active_low = 0,
; ~2 U4 a4 z3 E4 K5 n; L2 b .gpio = DA850_USER_LED2,
+ I. E( e" l. ]4 u .name = "user_led2",
& s# X0 W1 g7 t/ a" _ .default_trigger = "default-on",- \, t8 u: D5 M& { O: C
},
& z2 c9 B2 S1 o {3 a5 E0 Z7 [/ S9 B3 n
.active_low = 0,
, P& U3 p/ @- U9 X .gpio = DA850_USER_LED3,
; g7 z8 g2 V# H2 a0 |) y+ | .name = "user_led3",
. ?. U" `4 g: U) F .default_trigger = "default-on",: i! ^4 l3 B0 e7 F7 x
},
6 r0 }& Q8 Q' }( s% ~2 f# L};. ^2 S3 S4 `: u# q/ v8 _
5 h+ z- m+ Q. N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- J; g) [9 w7 i4 b
.leds = da850_evm_tl_leds,
- G5 g% Q9 A! d; S/ J7 y* s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 ?4 h! |7 ~$ M0 u7 Y
};2 y+ W/ k0 |7 p7 r2 i
( `) F+ Y0 @) {* z. X% [1 ]static void led_dev_release(struct device *dev)4 N' G. U- m7 N! C+ B* a
{
9 H! d7 ^- x, w" ?8 }4 b};
# h$ @1 \3 O( ^& _7 [- S6 Q: k9 e; c/ A# B/ k
static struct platform_device da850_evm_tl_leds_device = {; D( p7 h; Z- l" V+ ^. p
.name = "leds-gpio",
4 ?' F p2 Z) T3 m. [2 {! v4 A& Y .id = 1,
- Z7 E) }6 O' {3 n0 ~$ ]! F .dev = {2 ?& W' p9 _8 m! W# p& v% d
.platform_data = &da850_evm_tl_leds_pdata,# z6 ~5 \( b2 v4 q3 f
.release = led_dev_release,
# ]: r9 E2 |: J4 X } K4 T8 c% ^' C5 ?
};2 s7 a" O8 L' w# z; u6 p- l
2 [/ j/ c0 b1 q) F8 H+ E0 V
static int __init led_platform_init(void)( r7 I# W( D8 U
{
7 m4 \, H5 E& w2 q int ret;
# ]3 r* m4 t8 @% I& e8 k3 F3 S) ~#if 0' n: z5 F2 m% O8 p! l' _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ f% f# v/ n }; r. [1 ^ x
if (ret)8 M2 }& Z+ j" }# W4 D" `: ^8 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 O* [# h9 l9 x' m3 {" } "%d\n", ret);
/ o1 v; Y D7 }; g#endif' r* x0 b& M8 G. Z
ret = platform_device_register(&da850_evm_tl_leds_device);, Z9 Y& q" y5 r; {5 B7 i
if (ret)
B8 S2 S: V* G! ^0 c8 i- {3 r pr_warning("Could not register som GPIO expander LEDS");; w- L, j9 `: p
else: R: w+ L! N6 c+ c% F& P" s
printk(KERN_INFO "LED register sucessful!\n");
+ x1 q3 j9 D9 P( h t. ~6 W8 r; O
return ret;
* n4 R% C( j C}8 E' h$ I9 K2 X* a5 _* y3 W% V
; e) f* o1 Q' E: I: \- |3 J
static void __exit led_platform_exit(void)
" a8 {' m, s4 h% X* F5 y6 D{6 ?, F2 C: o+ ~2 h
platform_device_unregister(&da850_evm_tl_leds_device);3 @# @9 ^5 i8 T, l
+ F q# I$ Z3 d7 Y2 F printk(KERN_INFO "LED unregister!\n");
0 m$ h* Q0 }1 q( ]4 ?} U# d: M' D6 j
4 n! S+ O" ?/ b. Y% M2 omodule_init(led_platform_init);. I9 N% E. E3 b$ A6 d& {% W
module_exit(led_platform_exit);) N# @) E4 n x: a( d
2 E7 |+ D# m9 @, H# [2 Z( PMODULE_DESCRIPTION("Led platform driver");
1 ?: P& r$ t0 N9 [MODULE_AUTHOR("Tronlong");+ j; n5 ~* |/ f$ r; i$ |. ?, h S2 X
MODULE_LICENSE("GPL");
7 K. l O' P1 i) h/ ?: i
/ b s b) k Z |
|