|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: `* E3 i# x# q9 X" Z#include <linux/init.h>
5 Y4 P' g: q: s& G) Y B! X+ @# ]% w#include <linux/module.h>
# n2 M: ?& R) ?9 E5 ]8 m3 q* c#include <linux/kernel.h>: ]7 E: Z1 i& F& L
#include <linux/types.h>
0 u8 c k5 L' e) ?; L% p#include <linux/gpio.h>! e% d* O) g/ j* u' V3 w
#include <linux/leds.h>
+ ~7 T4 e# {7 A0 h3 j7 r#include <linux/platform_device.h>0 _$ T+ P# i4 |. Y1 l
* r/ c' ]. M- o" }4 m#include <asm/mach-types.h>
& e: x8 _9 }" B3 d6 Y Q0 h- ^#include <asm/mach/arch.h>
8 ?6 H3 E/ a( J; i- b#include <mach/da8xx.h>
5 ~" n4 A: }" z2 ]4 G: S#include <mach/mux.h>6 V) L2 X" }! K/ n9 h
$ B$ D* n9 { h" V9 P7 G$ g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 ?& n7 S* q) O6 k2 D6 v
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 g/ @! J5 A! h4 @6 {/ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) H. z* Z% O8 `4 D% Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 y0 x; m9 n9 f0 O3 T3 W. u9 u# Q
/* assign the tl som board LED-GPIOs*/
8 e* L j( E$ O* o' s8 S' F2 m; Ustatic const short da850_evm_tl_user_led_pins[] = {4 j" i$ R d: h) o
/* These pins are definition at <mach/mux.h> file */3 J0 \! q2 X' q/ [' f3 k; O& n' C9 V, @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) R. Y; X7 n2 O( r# p, z -1/ W5 V% l7 N% v& x' w
};
. q; u3 e; V' m) [/ K% b0 F- } J& |9 Q4 Z! T5 e% R
static struct gpio_led da850_evm_tl_leds[] = {. y/ b: P! q+ k
{3 J. t$ e3 d5 d/ G8 E* m
.active_low = 0,1 B6 O% a" o( i& v
.gpio = DA850_USER_LED0,
" s+ E6 j0 a5 s& h+ R' W% ~ .name = "user_led0",' Z7 Q; L3 S1 p
.default_trigger = "default-on",% t( }/ F' ]$ V6 l4 q
}, H; E: ]$ p* C6 ^$ _
{
% n5 k2 i7 Y: D0 ^. w .active_low = 0,
& t* I4 Q$ P9 p# X; c9 H: ^2 \1 W$ p) p .gpio = DA850_USER_LED1,. _* e! b0 ?2 x3 T& n& I
.name = "user_led1",
% Y1 Z, ?- k, w( G$ x" q" N .default_trigger = "default-on",! j* u% n5 e' j9 b; @
},# s" Z1 L% a8 U* Z
{7 g# G) Y( @! y' ?
.active_low = 0,
: i- C& J# W" k' z .gpio = DA850_USER_LED2,; A6 e# B9 `# @6 _. [/ U
.name = "user_led2",* Y5 {: t9 C+ x d
.default_trigger = "default-on",+ P3 ^( b! q% d8 ~
},& y3 J# R3 Q" t, ^/ b
{
V& b/ `! v( n% r3 v9 _ .active_low = 0,
" B' z- U5 `4 ^4 B! F3 m4 v3 q7 B .gpio = DA850_USER_LED3,
W+ q; M, N3 o9 [1 Y .name = "user_led3",
; r) L* }/ S1 z$ F4 u .default_trigger = "default-on",
2 f* b/ [, [3 @: R! i1 C },3 S. | V1 ~; k5 n" }/ F7 ^. ^" k
};
5 c; V. [! T3 u @* W0 f. i$ Q: c: Y* U {) a! w& c) k) N1 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' T5 h" ]( @2 a" V0 B4 M
.leds = da850_evm_tl_leds,
7 I# K% V6 [3 B: l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ a9 _2 o9 R; A9 c};
8 J6 l; r1 A1 N9 o, L" L ]* g( \! f
static void led_dev_release(struct device *dev): ]0 \, g) |( o8 T) G9 N! Q
{
5 T. v y [( w: C) R1 f0 |$ p V};* E' j7 E+ x2 d8 h% B% q' V0 F
( n9 O* Q" w7 P5 \0 I
static struct platform_device da850_evm_tl_leds_device = {9 `: [ e% }8 s4 _% Y; j- G' K, {
.name = "leds-gpio",
* A; m8 k, H! y$ C: Q. m! | .id = 1,/ G# Q& X0 h) p/ L }4 D; N
.dev = {
7 Q$ ~- g7 u( Y+ C7 x .platform_data = &da850_evm_tl_leds_pdata,
+ Z/ m( [7 `. v1 B' H. P .release = led_dev_release,
& B. z, _5 l1 ]: y9 U5 Q }
* ]1 }6 g$ z* P* T$ j5 z};6 C% ] t a1 ?3 k
/ }+ ~: Z1 P" l x; u0 @) c5 r* F) astatic int __init led_platform_init(void)
) m5 p$ q% i$ c6 j+ @5 C{
9 u- k$ c4 M; N7 R% ^6 Z int ret;
( J6 t& E% Z9 m1 k. i( l! X#if 0
. V3 ^. N$ s6 d4 I1 N# ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# Y# j3 f# ?8 g. B! `
if (ret)( A7 e& A& B* j! M. ~+ f$ z; T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ i9 ~9 P" B% K- X/ k
"%d\n", ret);
6 @6 Z% s' G2 [# p#endif% j- B3 m1 ?+ Q" l
ret = platform_device_register(&da850_evm_tl_leds_device);) f8 b& n0 Y Q8 D& h
if (ret)6 m7 C. W8 |; R m* Q
pr_warning("Could not register som GPIO expander LEDS");
* b4 ^( p" T1 l% u U else ^0 @6 J0 M+ M+ R
printk(KERN_INFO "LED register sucessful!\n");+ Z& }, I" I4 y8 o
% ~, }: F2 p5 N; O7 P return ret;
% i* Z. }$ G L7 B}
3 M4 y6 \# X# C! C
$ g1 P( W" M2 {; @9 Estatic void __exit led_platform_exit(void)
6 W, m0 S. |" O/ x! C{" K4 e- Y- i- d; N7 }$ n; w+ e
platform_device_unregister(&da850_evm_tl_leds_device);( n: @5 |- u% j2 ?, [
l- L' c. A( [- l/ Z1 T N printk(KERN_INFO "LED unregister!\n");
" x4 q8 [- Y- U4 o {}
, j( c( g4 d; n( @1 W
2 L2 W2 _0 z# E3 Q$ H' zmodule_init(led_platform_init);0 \9 d, L4 f, N2 l& {# y
module_exit(led_platform_exit);( M# |( H6 C/ q- i r" s- e
0 V9 h/ q2 _3 b& Z) q8 y& U4 S8 J
MODULE_DESCRIPTION("Led platform driver");
# V4 b: i. U- P1 X; bMODULE_AUTHOR("Tronlong");6 `2 | S. `" s- q j6 P+ x
MODULE_LICENSE("GPL");
: | _/ F+ Y5 a. D3 R2 H
! i8 B+ k) Z: H" u+ p8 { |
|