|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# t. E. X2 {9 w7 i% z7 d& C) G* i
#include <linux/init.h>7 o- S/ S. t3 G( |$ n
#include <linux/module.h>
/ L5 \8 e, C P( `#include <linux/kernel.h>- I3 g1 p6 t( s" ^+ o5 r
#include <linux/types.h>! s( o) [+ A- T: F& e5 |. C
#include <linux/gpio.h># u9 e4 N7 I" R* N! [9 U
#include <linux/leds.h>5 ^' f) o; R' ]- m
#include <linux/platform_device.h>
% ?& d; D) x; z4 e
" q5 k2 h" j* S0 h1 F# j#include <asm/mach-types.h>! ` D0 x# Z7 l% t) o
#include <asm/mach/arch.h>' T' O) X. Z2 A: I; `- p
#include <mach/da8xx.h> }7 ?- |1 S3 J" w
#include <mach/mux.h>, n j0 S' k5 I4 L- V" G: o& {
- p+ q- f) P( Z# a* u3 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 b& T M G! ^: a) q; e1 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 j: P2 n7 K$ R1 z1 U9 ~4 X! |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! }- B$ V' g- e: U% i/ r/ X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 i& T4 ]' P4 e1 c2 ]' l, K
/ g) A$ G7 Q" s4 w9 [6 f/* assign the tl som board LED-GPIOs*/
- P% {5 O' |2 f% E1 Y& Pstatic const short da850_evm_tl_user_led_pins[] = {# \& O0 o& v6 H% t
/* These pins are definition at <mach/mux.h> file */3 y& K- y3 O4 R; Z- o5 B" [( k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* z2 X# i8 N/ G! F8 B
-1
/ {5 C' c( ^/ _* T7 d};
! ]0 w! }7 q' [3 I( {# E" ]' e1 d: U: i/ L6 {+ c* u, {! {2 e9 P5 C) ^' k
static struct gpio_led da850_evm_tl_leds[] = {, h( _$ d# C. [ Y
{
- M% i6 [; o$ _9 L" {( G- A .active_low = 0,7 x" p; C" d/ r' @
.gpio = DA850_USER_LED0,% r' B |4 a& A, v7 |" p
.name = "user_led0",: L+ u- t$ B2 }7 S+ h' T# O- Y! m
.default_trigger = "default-on",
# V# s4 g5 y% _: c },* J+ ~2 y F- N$ `; F0 D) D! T
{
! E- p% v) ]+ B .active_low = 0,
% r' [' m8 ]* c! u! e: Z% |9 X .gpio = DA850_USER_LED1,
7 _4 a- v* T) |8 r. p .name = "user_led1"," l0 n; o. g) C( @6 H; @
.default_trigger = "default-on",9 |7 i5 ]- c/ k# y$ s) g
},; K+ c1 g6 R0 A
{
: Y7 I+ U9 M' x4 e .active_low = 0,: u1 @& M8 Y9 g8 Z7 t/ [' Z
.gpio = DA850_USER_LED2,
% q1 Y" w- e$ x: g" ^. G% } .name = "user_led2"," q n* I: b2 n, l
.default_trigger = "default-on",) N! K2 O Z( [" m- ^
},6 ^; X2 z9 |& g8 y U" a& K/ _
{
, _% J* D% c+ e, K9 M7 A .active_low = 0,
4 g" M) a' q$ W, x- X .gpio = DA850_USER_LED3,# f7 K [$ i3 Z/ R. T' c+ ^
.name = "user_led3",* G0 d& ~0 Y; ^- ?' D& L
.default_trigger = "default-on",. H, A: m& s1 f9 L. F ~
},2 `% c) S2 W; i$ v' V( v
};
5 t* v2 r/ b9 Y7 K. N9 w+ _# T/ I/ w( {. R# N" N r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { l# X) z h8 R$ g8 d
.leds = da850_evm_tl_leds,) J, }+ n6 Q1 N# D: H1 b1 d
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 q" x, x( N$ b5 n0 o, i8 v8 d( z
};
& F# o. w" |7 F# G' }$ }: r
7 d2 [9 E$ G0 pstatic void led_dev_release(struct device *dev)
8 N, p$ w3 {+ C4 E{
0 }4 V. ~. t( c; X/ q4 @};
; E5 W7 g1 s: M X: ~% j7 N5 x2 ~
& e$ k& e2 E- l8 K9 Wstatic struct platform_device da850_evm_tl_leds_device = {
) A# n! l7 Z; g; b .name = "leds-gpio",
, b" x* j6 P9 k4 \ .id = 1,
0 r/ v) }* q' z' g( F+ c" b' q3 a .dev = {
" n6 X4 `- T1 Y' ?( W$ } .platform_data = &da850_evm_tl_leds_pdata,
$ W& c4 q; P" a .release = led_dev_release,
: Q, N5 i# g1 Y }
* `/ w, W+ \$ p4 X% P9 r$ k! d};; g7 N8 q6 V( ]% K# A1 \" R( U5 \
+ O$ ~* {( A* rstatic int __init led_platform_init(void)/ Z0 H, ^3 W) p
{
! u, m7 i5 M9 n int ret;+ [6 y8 S; L. f6 J0 e0 I1 a
#if 0
; _9 j: t! h! s" B9 Y& m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# Q% B* p+ N. p
if (ret)
, f, ?/ H4 Z0 h7 g' x ?9 g8 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ I B9 G! H7 J N: O( Y# `# Q9 Y. \: o
"%d\n", ret);, v) k+ ?6 Y6 z2 W, e0 M. w
#endif! J# s: Y0 A, _7 a
ret = platform_device_register(&da850_evm_tl_leds_device);
0 p& Z9 [: m4 I" _3 s if (ret)
7 B/ x) v0 S g- a7 r/ z& R" g) } pr_warning("Could not register som GPIO expander LEDS");
5 e0 N4 P, ?" \0 E else! M! j; B4 J: M, T, u
printk(KERN_INFO "LED register sucessful!\n");; M/ a% c5 C4 d6 f8 m0 b: n
& \' c* M; D" {4 k% H, Y; w return ret;
" x! O/ H2 i( g+ \& j* |}
8 Z! W1 T' m! d
1 z0 V5 p/ ~4 `: l4 B7 Z( Ustatic void __exit led_platform_exit(void)
8 C# a3 I7 ~6 |0 n0 s; |2 `8 j0 m{3 p: {& t* s2 r% {
platform_device_unregister(&da850_evm_tl_leds_device);
5 k9 H) M' z: o$ z G( I7 y' ^- K; |& [) m
printk(KERN_INFO "LED unregister!\n"); q" p5 j7 H0 U+ G5 j4 g5 P
}
0 z9 Q! t( s( F$ ^8 P" ?
1 l- x0 t, w7 f2 \2 a) i* @* y+ Omodule_init(led_platform_init);" H( G' F( h s9 L* |4 `0 a
module_exit(led_platform_exit);2 \* w+ U1 d7 f6 }8 |% D5 ^1 @
2 I0 c+ o& D% S. t. Y; \: }MODULE_DESCRIPTION("Led platform driver");
+ H& s3 t& L$ D2 W5 wMODULE_AUTHOR("Tronlong");
$ | M k+ a- }1 C( W2 EMODULE_LICENSE("GPL");
& E! S9 z% D6 q
% n x5 B: x& M# @- \# { |
|