|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 x2 W) ~" `7 v# V#include <linux/init.h>+ U2 |" h$ c* |. J: ~# ~) E
#include <linux/module.h>
8 H8 A+ Z: W- S1 O#include <linux/kernel.h>0 x9 ^+ q1 m' M- j
#include <linux/types.h> a2 R4 x# J# n) T
#include <linux/gpio.h>& |+ h! L4 m, k% X( i% L
#include <linux/leds.h>, }4 _/ |* i: p, z
#include <linux/platform_device.h>
! \' z4 ~5 \* [0 L2 g9 [+ L5 F7 y. G
#include <asm/mach-types.h>( p& {1 _# a; q* {( w, h' c
#include <asm/mach/arch.h>
% g/ P0 z4 e& ~' E0 y! S8 ~#include <mach/da8xx.h>/ v) C3 m7 h5 P
#include <mach/mux.h>% z9 u% p3 x8 @: ?* K- c" C
" I% ~1 g6 y( h! b' F N/ B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 y, x. W+ F7 Z) x! \3 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! ?1 A, g s- I, q4 A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), y/ P4 ?3 g. Z) r% W0 D! @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 F2 Y! ]) x( b4 w0 m
' t9 E) }3 X$ l) w( K/ {/* assign the tl som board LED-GPIOs*/
9 a; o; o9 {9 Z" n& ^static const short da850_evm_tl_user_led_pins[] = {$ t& {4 ]5 _$ U+ U, r; }; n; f
/* These pins are definition at <mach/mux.h> file */
& |5 ?: E; p6 [: n' x2 b5 C4 B: U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" r; ^: Y7 F5 V& ]& @3 y% i2 [ -1
- W, b+ p: {1 I p. n* h};
' j& I% N( n- O) h! r% d
7 I: v; a# z4 T/ B6 Z! I" Q, T) `static struct gpio_led da850_evm_tl_leds[] = {/ s5 c% o7 n0 d9 v, O
{
2 \5 C* G4 \( t+ e' J7 R .active_low = 0,+ i& s0 B& D) X# s$ C
.gpio = DA850_USER_LED0,
$ J7 ^3 K9 l& `: T .name = "user_led0",2 \, g. ^/ ?1 y% |, ~# [9 V
.default_trigger = "default-on",
( F1 X; }! @6 K, c1 l- `5 f9 e0 S },; _7 q0 W' @6 ~1 U
{
& i" l. e. W l4 s2 {- R .active_low = 0,& j( x. {4 S% m1 Y0 Q
.gpio = DA850_USER_LED1,0 v/ Y8 i- B5 M. s0 M5 U
.name = "user_led1",
8 p& p3 u- O$ m; O% Y8 s .default_trigger = "default-on",+ _5 U8 ?5 U% W7 l
},
4 H/ q# e; ^6 R8 h4 | {8 V8 o8 S$ B' o
.active_low = 0,5 g+ B/ u, C* Q( a3 a& {7 {
.gpio = DA850_USER_LED2,
' p% V. r( ^- e- z .name = "user_led2",
9 T& A4 F4 ~2 U/ i$ F O* b1 g .default_trigger = "default-on",7 H- A0 W$ E/ ~' _2 G' V
},
9 m5 c8 y1 n6 O. t/ r: p+ @& o {
5 t G" x9 \; _7 M; T( a" L% o .active_low = 0,. h' X3 V; P) h9 \" h" E
.gpio = DA850_USER_LED3,' x6 w2 N5 Y2 s% b* ?+ U) X5 K {
.name = "user_led3",' B! o. S0 K5 J0 {) X
.default_trigger = "default-on",* M& x! h# x( I9 z# \
},
4 f) I* L8 d" K};
' _- g, \9 z L, y! T
+ q$ Z7 G& Y! {9 Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 D: E4 x2 I: a v3 K, D0 l% k: K .leds = da850_evm_tl_leds,
2 f- b+ M7 |1 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 t; F+ J; e0 m1 @: M1 a1 c};
5 d* A4 t4 s3 n: I) d
- G! o4 t9 y* y4 z/ ~: kstatic void led_dev_release(struct device *dev): M _+ C6 F3 S' |. X+ d& x, R* K
{( X, C& ^* |4 D8 h$ \3 A
};
2 A& G3 h& J# {/ c7 Y1 i K9 d. c! P7 u4 a7 j
static struct platform_device da850_evm_tl_leds_device = {
8 ~" v2 U3 m8 c5 Y0 H3 J- I .name = "leds-gpio",
/ d1 J2 }# Y- u4 I+ c f .id = 1,$ q5 W& s! M0 P+ W( [
.dev = {
( T$ J9 j+ W% Q' \7 k& s8 a .platform_data = &da850_evm_tl_leds_pdata,
7 w. S8 X, T7 A J .release = led_dev_release,6 O$ e0 b/ d) F, g; z1 `
}
7 o, C/ C. q& }5 ?9 Y1 }};
5 s7 g+ R5 G8 |1 R* |# A; G; U# T* N# c; m
static int __init led_platform_init(void)! S* S2 `1 J% }! G' \
{. w' N8 t, n2 a! `8 v
int ret;8 ^$ e/ D1 o- a5 S2 R9 S4 \
#if 0
% e. b w, K+ j$ ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 W* U8 l/ [. S; P% x
if (ret)+ }/ _% g% u8 l1 `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ d! p) ~/ s5 `) r+ A4 s2 B1 [
"%d\n", ret);( B# ]' e$ q8 q
#endif& d7 P* j4 G0 V7 c& _, K2 F: S
ret = platform_device_register(&da850_evm_tl_leds_device);. }/ f0 D- q: ^
if (ret). m/ t- v5 J! y6 w5 i, S
pr_warning("Could not register som GPIO expander LEDS");
0 x; ^$ [2 S0 }6 C/ r0 H! V3 F else
$ h/ [3 P- m8 n printk(KERN_INFO "LED register sucessful!\n");( ]9 n q( l: ?
8 j5 z" ^& m* H return ret;
+ u+ o0 l' q3 T0 S9 s}) i4 l% |, m8 W1 V
( v9 ^; X# P1 r) vstatic void __exit led_platform_exit(void)
( w# V% S* T, O# W8 k5 G1 q{$ O2 |4 s( P( M+ E; L. W3 |
platform_device_unregister(&da850_evm_tl_leds_device);2 d* s }; L, ?: z1 e2 V3 y
: O8 R0 E9 w3 l: U( p
printk(KERN_INFO "LED unregister!\n");5 m) [& l1 X2 Y% q4 Y% {
}( p: n, g W( l% \
7 t% K9 c6 N; Pmodule_init(led_platform_init);1 |+ V) m5 j! t+ ]
module_exit(led_platform_exit);
: h2 M ]/ {: @: P8 a. }$ c5 h4 h4 R
MODULE_DESCRIPTION("Led platform driver");
3 k. g+ R8 P: ~- C4 P/ uMODULE_AUTHOR("Tronlong");
6 @* X8 J5 |. q/ ~5 Y2 j$ uMODULE_LICENSE("GPL");8 d3 [; o- Z3 e u( l+ K5 @! [ Q
8 g5 J! ]4 x/ n1 |$ W! h) }/ j( L% f |
|