|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" Q1 N' o) X! D$ w#include <linux/init.h> D' [ P) D4 p9 P
#include <linux/module.h>
1 ]( {9 I- k0 D; ]. m t#include <linux/kernel.h>
% v R4 q/ [* x#include <linux/types.h>! o6 _0 j! ]- `
#include <linux/gpio.h>
% O( {/ O3 G: M% }- P( C#include <linux/leds.h>
" N# M2 N( `* \: F9 Y# X#include <linux/platform_device.h>
5 X- j6 K$ Q! ~: s1 S
, R" B# c# H8 [! R3 D#include <asm/mach-types.h># J( h3 F- L6 M' a
#include <asm/mach/arch.h>+ d8 U0 y, H7 [6 _* J: S
#include <mach/da8xx.h>
2 Q9 ^0 X$ U$ M; c# W# _#include <mach/mux.h>
$ N5 t" S4 f& |, j H# T5 O6 r, C. V4 }* M3 }' R) g/ D$ v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ V1 Y9 l6 t; z( y7 f8 Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ ` N {- M6 F' x5 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" O8 d' y' a8 {9 `7 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- d2 U: Y( T# c9 o6 m r4 m0 y
/* assign the tl som board LED-GPIOs*/
. p ^! X, C3 |" a$ g. n2 a2 Mstatic const short da850_evm_tl_user_led_pins[] = {0 U7 G" s, `2 ?# a
/* These pins are definition at <mach/mux.h> file */5 c; D( } m% H( o9 ?* c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- t5 a1 [, g) e' W( X- b, n
-1* z( C6 e7 j) a
}; e) {( b% L ^) _! @
, O) A6 N6 L1 F- k4 ?static struct gpio_led da850_evm_tl_leds[] = {5 a4 g5 ~( H: X5 Q
{1 a+ t, E, u0 u! V
.active_low = 0,) y0 W; ^8 b8 M8 s8 [
.gpio = DA850_USER_LED0,
) l I- H6 C5 w& g; J9 v5 F .name = "user_led0",4 ^4 O+ q* ]0 F% j
.default_trigger = "default-on",; u6 S0 |) M6 B1 I I
},3 ^. D) U2 o' ~: \5 v9 H5 [
{# t* t* ]& h: j1 e4 _3 D2 I* v
.active_low = 0,8 g1 E# }+ D( Y: s& L) w( ?
.gpio = DA850_USER_LED1,
% L/ d7 N! Q( u; C7 P y9 ~4 B4 p" a .name = "user_led1",
8 O j+ a6 V. j .default_trigger = "default-on",
% F" E( ?" ^5 i. }6 X },
; K3 q! \+ u. e4 w8 k* ?. s { R9 w8 C1 _. h# X! Y$ D: J
.active_low = 0,
7 y p" D0 d, b# f .gpio = DA850_USER_LED2,
5 ]' q$ ^6 o( }- V# m .name = "user_led2",/ L s$ `' d- D( ^) Z. s
.default_trigger = "default-on",+ T- ]% K) Z, v6 g0 [
},
4 r3 B, U* a: |, F" ` {5 m1 A# B1 i1 w; P; ?+ h! K+ ]
.active_low = 0,2 B* ~2 ~' d" h! x N$ c) v6 @
.gpio = DA850_USER_LED3,- B/ r0 V; v% t" u
.name = "user_led3",$ o, }3 ^# O. i; R
.default_trigger = "default-on",
$ o2 _$ q- d& J$ r$ E },
3 n5 O( C8 R5 n9 F7 p- ^};
: V; r/ U# F: ]
6 X+ @; t! O2 S- }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 ?" k1 a: R: D1 D. z: Y* v .leds = da850_evm_tl_leds,
! F! i6 z- K8 c' U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: r4 ` o M* J' _- D
};
% g3 s. h, X* \3 ]* |7 S1 S0 r1 c8 R% c# g
static void led_dev_release(struct device *dev)0 ?7 X+ H3 A6 G+ l# P- g
{- G0 ?& t4 P8 I8 A
};" f7 ?& e) r3 _& C# u4 c; M
* Z" X+ x, c, G/ Astatic struct platform_device da850_evm_tl_leds_device = {
& X+ Y0 b2 I7 o& q1 H .name = "leds-gpio",7 d, F( T7 _) s/ Z ~* s5 }
.id = 1,
+ \2 ~5 B2 }' u. O, c' c0 w .dev = {8 S0 {; M& y# ?. a2 g
.platform_data = &da850_evm_tl_leds_pdata,8 ~4 H% Y8 L' A8 Y7 K
.release = led_dev_release,
3 k5 Q" O8 V6 f* }1 `+ w }
% f7 F% E$ y& {8 L6 J% E8 M};+ f+ b6 H& b3 q% ^* G
8 P# x( P" k4 qstatic int __init led_platform_init(void)
) w2 m0 i7 V! U" i, S7 U# v{
, t1 f4 k" @* L# k* m; m) j9 v8 E9 G int ret;3 s+ G+ Y' b1 z
#if 0/ f9 W" L7 w5 R7 \! O$ S9 G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ J ?0 S! L3 s: Y
if (ret)0 t/ a3 f0 N: P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 j3 x7 R4 [9 |1 a! n0 v& F
"%d\n", ret);& ` ~5 n9 C" ?( Z0 {; _
#endif
+ r8 \' w( `' w- W$ [1 z( ^ ret = platform_device_register(&da850_evm_tl_leds_device);
; T) u. W* f3 p8 G' _6 o if (ret)' H0 b7 w. Y7 |7 X
pr_warning("Could not register som GPIO expander LEDS");
8 J: s, H# P3 O7 ^, a. j& m else
1 T9 \0 b) o; b! _2 H1 A printk(KERN_INFO "LED register sucessful!\n");
9 F9 e1 s: N1 u! Q! w
0 m' c& f7 X" c* s return ret;. y' ?1 g* X- X
}" m, y' Z2 `9 Q5 p; X3 N
9 k8 L8 C* N/ b% s' n" W
static void __exit led_platform_exit(void)3 b/ `: G5 Y0 F5 t% T- l* ]
{
5 [4 _( ], Z: H; ^1 l6 O1 F8 m! d platform_device_unregister(&da850_evm_tl_leds_device);
6 u' \" L* \2 {) z- T) ?! v" T& \ Y! h
printk(KERN_INFO "LED unregister!\n");& `, `8 z. S9 \/ R
}
- r2 P% r" F6 T Y4 r5 Z
2 s9 o! v, d& q' v" |; umodule_init(led_platform_init);
" K" r# `' o3 x6 n. f* d' z Bmodule_exit(led_platform_exit);0 M B) V9 L Y1 |# z) ]
0 T" ^- W* j8 w5 Z+ s
MODULE_DESCRIPTION("Led platform driver");
* F; x& ~: q0 Y& J+ eMODULE_AUTHOR("Tronlong");7 ^1 w' g8 N- e; N
MODULE_LICENSE("GPL");) s6 X6 |2 T* i. J* r
7 z4 X+ ]9 V+ u1 N6 `
|
|