|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ `4 u# O3 o' H" c8 d0 s- F- e) v
#include <linux/init.h>
. E- J; n8 M: T#include <linux/module.h>
. G! x4 b8 q2 z#include <linux/kernel.h>
, I; _+ J ~' m7 P" D; ]* g#include <linux/types.h>1 D* G. y& s0 [( F) j `, m; z- E
#include <linux/gpio.h>
) X+ p3 N( x2 _4 l! n7 f8 `#include <linux/leds.h>
* H6 U' Y7 ~* v( x#include <linux/platform_device.h>
0 K, q3 Q( E2 H) E% q* ~, e2 f
2 X/ V5 T" q$ B: r0 B#include <asm/mach-types.h>1 m/ T1 \3 a$ P! G: J' M w
#include <asm/mach/arch.h>( E& _6 s" m- ~
#include <mach/da8xx.h>/ z) T- c5 f9 U% o% u% [' C
#include <mach/mux.h>
% h2 d% a' w# E+ g! ~& B
2 e1 l* ~/ D0 [5 u7 N: @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% N, S6 J& ^, m* @/ y, ^( y- k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! T! d0 q; c* T }0 D3 [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ }7 S m7 x( j3 t# P7 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- g; d& T R3 U- k/ R1 Y
5 v3 w' z4 Q. [: j. i/* assign the tl som board LED-GPIOs*/- w6 X$ N* Y) }
static const short da850_evm_tl_user_led_pins[] = {
2 ^2 L; x* m! R; V8 p1 D /* These pins are definition at <mach/mux.h> file */+ ?, A$ m* H0 _% F1 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: e% V' }5 g- J2 C v- Q3 F6 x -1% S( b. ?# k* x5 l8 X
};- M/ K3 }$ p; ?7 O; x+ _6 p( R
! i3 A& L8 `% k; V' z3 i; gstatic struct gpio_led da850_evm_tl_leds[] = {3 N% b! c) z' Z4 t" n5 a/ h' @( n
{
6 t+ }# a& ^7 ]- [. C .active_low = 0,
; e+ M2 p( r* n* ?4 s( R8 ?# O .gpio = DA850_USER_LED0,. A. o5 {9 f$ ~* b. n9 s2 o
.name = "user_led0",/ s1 a' C1 H9 u& _! X6 p/ P$ O
.default_trigger = "default-on",; D" ?/ r6 i5 X5 j
},
" Z( f5 K& D( P" w" k m {
. r2 `. T% i+ @* J; z1 j- U .active_low = 0,! y* I- G6 a& P3 x1 m, m3 Z$ n1 w
.gpio = DA850_USER_LED1,# `$ X. e- ?0 }
.name = "user_led1",
& G* b) ]) e1 o .default_trigger = "default-on",
/ k: _1 b7 A! f3 j' [3 _ },
7 c% x7 c0 R! I! h. }. J1 j {, C& M4 K3 [0 @! S' O" Y- K
.active_low = 0,
4 l0 R8 @; d: c/ v .gpio = DA850_USER_LED2,* S( D! z: b% M/ j
.name = "user_led2", G4 [7 s) n9 ], Q/ j# R* V
.default_trigger = "default-on",8 L3 b; Z: T/ f0 t- |
},, j$ P- U& |5 b) c& H8 y, D
{
2 @( r* T! c+ R% F* j; A% e .active_low = 0,5 s* ?' @ P9 K6 q
.gpio = DA850_USER_LED3,
' Y# \* [1 V2 {( e9 b .name = "user_led3",
; t) ?" k; D2 S .default_trigger = "default-on",
% d3 x2 z& w" q },5 p3 ]0 S4 Y6 X! s& |- D
};
$ H% Y& e% K" ]
}5 ]7 y2 O- X, m# J6 Z ^, H9 pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- i/ r2 T9 z% G .leds = da850_evm_tl_leds,
8 H: r* \! ?, d5 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- h. J7 a1 j9 @0 D" u" ]/ N
};
$ q; ]- o( l0 ?: Z. {
! o& e, j1 H3 B% Y6 |; x4 w8 @static void led_dev_release(struct device *dev)
* M, d& S! M- ` {" R{% W, f! Q! A# \0 \( r
};
, s0 H& V5 }( S" {% Y6 t$ @0 A6 K
static struct platform_device da850_evm_tl_leds_device = {
" m) {3 n' ^/ { @ .name = "leds-gpio",9 d! }7 S) n; x7 \# B* x
.id = 1,
& W j# p8 {/ }1 r; x .dev = {
- }0 [& H2 P; v. c5 X7 U# W" F .platform_data = &da850_evm_tl_leds_pdata, t, D& K3 B: A, |3 ]( K
.release = led_dev_release,
1 |% p; |7 ~0 i: {8 N: } }
7 i1 `, b- l( j: B/ C# J8 }: \};0 g. p9 |& Z ?4 [
% Z) }1 `( [( Lstatic int __init led_platform_init(void). J) b. g. H/ e) f) F1 |* M
{2 y: h( g# g* b6 H
int ret;) R& c3 [! m8 t5 G2 M* e7 S2 U
#if 08 u* \! S" \, l; F/ t* _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 V! p* {& m+ a0 h6 l2 i" ] if (ret)
9 ~# I8 M! a0 I& |9 D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 J& N5 S! A' P
"%d\n", ret); H) b0 B: b# ~: f3 c+ Y& m
#endif3 s, s* _+ G& Z4 C" g# G
ret = platform_device_register(&da850_evm_tl_leds_device);
' U# q( |9 m0 i8 c) v if (ret)
6 I( I1 Z: G9 P, W+ p pr_warning("Could not register som GPIO expander LEDS");
) O3 S. o n& u% y- W& _ else/ G$ S! J# C) c: e5 \# ?! u0 {& {; r4 C! Y
printk(KERN_INFO "LED register sucessful!\n");
7 _8 v4 \1 K/ w: {8 V" y$ [5 y) i, ~! H# Q' C& V
return ret;; v9 d+ Q' G% W9 ` Q# S* Y
}9 K8 k9 |& g4 e- b6 j; ^
9 Z9 M& m& [( F1 E; Mstatic void __exit led_platform_exit(void)
& y% N. g% V' d/ C$ p% E{( J; }; M$ {( t9 `" d( I, t3 b7 p
platform_device_unregister(&da850_evm_tl_leds_device);' i* I! j9 R9 E
$ Z3 A8 ?. v4 t7 o* i% U5 g5 G
printk(KERN_INFO "LED unregister!\n");
, s! D& R |" h( a1 d}
: k9 h3 S6 r5 l; n6 H3 x4 u3 g- U$ f2 e7 T
module_init(led_platform_init);
/ d+ W4 `! _) b! Z* Amodule_exit(led_platform_exit);+ U" I0 @: M% i0 ~# H$ R) T& Q% W% H
! G! i$ J, A( @
MODULE_DESCRIPTION("Led platform driver");5 ?9 h- w y: v9 q, b* P& a9 @
MODULE_AUTHOR("Tronlong");
1 J! o% c' g- H( yMODULE_LICENSE("GPL");# W3 l) a: ^9 F+ c
& g6 v% `$ M1 W6 |* Z |
|