|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' E! A t3 X1 ~5 b3 J5 w#include <linux/init.h>
4 C% z8 y+ k& p' ?9 f#include <linux/module.h>
6 V+ Q% {9 F' O3 U4 @#include <linux/kernel.h>3 ~) Z! l7 ?7 m6 I$ C
#include <linux/types.h>
3 e) N' K. i8 j8 r# `$ P1 L#include <linux/gpio.h>
6 [2 u7 Z) f% ^#include <linux/leds.h>6 p0 W- A6 f4 D! Q0 ^' Z4 K( x( d
#include <linux/platform_device.h>* L2 k: K- {+ B' ]5 N4 P" }$ m
: Q7 F1 U. {' z$ x8 r/ v$ \) w
#include <asm/mach-types.h>
4 w8 w" ?5 G- B( t#include <asm/mach/arch.h>
3 P m; K& d/ w2 K7 I#include <mach/da8xx.h>
9 d% `% o% w, ^% f9 r) K#include <mach/mux.h>
, P6 B- ^% u! f3 Y3 J# s( m, z* u5 ^) C: K m3 d u/ E5 m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) s2 |/ d2 _! K0 N4 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" h+ i' I1 J; D& S) R- D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 b4 o# \& Q4 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 \' x! q! j* B4 J. L
9 R0 F7 X7 G& T0 y' I
/* assign the tl som board LED-GPIOs*/
# c, S$ K: u: H# a2 O( kstatic const short da850_evm_tl_user_led_pins[] = {
3 _" l% U) \ @ C( F+ i /* These pins are definition at <mach/mux.h> file */
( v5 I# T5 U1 ]5 @ k6 @) O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) q9 p( L: j- ?* f. u
-1
1 I! \! A$ n9 \' X! n5 B};# R- c- L! u0 s$ U( I
1 E7 H; N% J' y% y2 n
static struct gpio_led da850_evm_tl_leds[] = {
9 r- t5 v7 N* J* _1 P {
$ ~/ M* y6 ]; i$ O3 W# o .active_low = 0,0 J; z6 x8 [4 H0 |& }( H) L
.gpio = DA850_USER_LED0,4 d5 z) j( E, W3 o* ]. c5 y
.name = "user_led0",' N0 P) j2 T; q
.default_trigger = "default-on",
8 o/ p- j1 y9 F$ ~5 D },' `1 R: x9 o Y: l: s4 {# k- o
{
7 K- z J: U' [# K2 ] .active_low = 0,3 f& a7 l& u# B& x# L4 K
.gpio = DA850_USER_LED1,4 r: e. E( v% P
.name = "user_led1",5 P, W, k0 q7 t% B
.default_trigger = "default-on",
: }8 M7 z1 W3 j2 b' E, g4 o },! B. k: d# @9 v; E' C1 U
{' W* ], W7 b! s4 U. h% V3 v) p& ]+ e
.active_low = 0,$ b" y' x7 W7 G2 h; ?# g7 H
.gpio = DA850_USER_LED2,
" a' v. Z! J$ o0 R9 ?+ G; Z8 a .name = "user_led2",* Z/ i2 I- f# d) A! G2 s
.default_trigger = "default-on",
0 f8 c! ~6 g' ^ },9 z! _9 A% Z0 f$ Q7 B( Q: Z
{
" m9 m1 ]' w" }# S2 p+ | p( }$ _ .active_low = 0,
: |) ^* Q) { G% ~9 L6 \ .gpio = DA850_USER_LED3,: S; B! J+ m; y' _( C2 S/ \
.name = "user_led3",7 |1 K7 Q, G0 ^& C
.default_trigger = "default-on",( w* e, |' E2 m# O# ]
},' r6 l% M2 \, j5 `3 u8 ?
};) v; z5 b' F( Y, X+ n) Z
: ^1 S8 B7 g8 ^' Q& t& C' B7 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 [6 b: C S! M! m% w$ x x
.leds = da850_evm_tl_leds,
0 ?5 z, y1 f' w# f9 }& @6 @0 T3 A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 S3 d4 M2 }4 ~! x b1 |: j8 j};% c) O2 h9 ?8 y
( B7 e. I+ R1 c( A: u0 ?% V% t
static void led_dev_release(struct device *dev)
K5 P2 X5 t& M{" d, K8 |0 W$ Y. A3 ~
};
/ N: w1 G# k9 b# Q2 B, K1 c% f$ K7 ^" Q. p) `
static struct platform_device da850_evm_tl_leds_device = {
# A( T, G2 {* {% t% T .name = "leds-gpio",
0 H3 w! ~1 a5 \& k3 _6 R .id = 1,
$ X6 u/ P2 h' a! Q; c .dev = {/ y9 ]4 B4 Z6 p* w4 Y5 Z
.platform_data = &da850_evm_tl_leds_pdata,
( M! }( w( f7 u .release = led_dev_release,
$ ^5 U+ v3 ^- D1 I# [0 \ }& F @. b" q- i7 P1 F0 P
};
6 }) F q- J: L2 [" f1 ?6 q; F: G+ n5 n) |) u$ ]0 J) Q
static int __init led_platform_init(void)
& L. ?3 S5 H m5 [ L% _{
2 D& c4 Q7 T: h- l int ret;
- r/ w7 K- F3 p5 C$ Q, ]9 A#if 0
" ?+ U: Q/ U2 k: l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, N5 L- _8 C1 V* y# c2 z" E, `
if (ret)
9 j1 m8 z& i5 V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! b4 S1 _: w" |7 Z4 E
"%d\n", ret);
( }: p* t% T0 a! U#endif& \. s: i& |; d' _+ @
ret = platform_device_register(&da850_evm_tl_leds_device);
. X! a9 m0 d) C6 h& V" y0 n if (ret)( Y2 m( `4 Y$ m' F6 b. ^2 V7 l8 A
pr_warning("Could not register som GPIO expander LEDS");( ^- A' }+ Q: r& F
else
* _5 n3 G+ ]( n) Q printk(KERN_INFO "LED register sucessful!\n");& ]! c3 f" y* f) }
+ K% a# A% s4 H4 d3 F' L return ret;
1 e0 R4 r5 R, @3 \3 Y}5 y: m/ \) I; A0 g9 v
% N. ^0 Y0 |7 lstatic void __exit led_platform_exit(void)
7 ]0 G; Y& e( }: T/ T- G, w{
$ x0 R- L. [: @ l! |1 m5 o platform_device_unregister(&da850_evm_tl_leds_device);# ~- p+ O6 G |9 Q
/ \4 G; P0 b. Z5 Y printk(KERN_INFO "LED unregister!\n");: x* q: \1 r9 A& z$ v+ O* b9 z r
}
' I0 @! f* o! _% [' r1 N( P) `) X1 z3 D& H5 u3 s
module_init(led_platform_init);# t t" i! o/ a
module_exit(led_platform_exit);! | @+ }1 Q7 b4 R" ?5 P( P8 N
1 ^% u5 z3 l1 O1 t, CMODULE_DESCRIPTION("Led platform driver");
$ H4 O, ?/ i) vMODULE_AUTHOR("Tronlong");
- X" q! P" i) yMODULE_LICENSE("GPL");
0 {3 i6 I8 q. F3 q f& k6 [2 z9 M C* X' V
|
|