|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* h3 S5 s$ z, c" W/ x9 t8 T7 C
#include <linux/init.h># i9 l, G7 P: p& G/ W
#include <linux/module.h>
/ o1 `% a8 X. z" j+ x#include <linux/kernel.h>
+ T. Z' ]# j0 b+ x$ _7 x# h) d#include <linux/types.h>
8 }* ?$ p1 J3 S5 P+ E* A#include <linux/gpio.h>( _* _ @2 X9 I9 j4 [( A: k
#include <linux/leds.h>$ U& N4 c2 q4 y! d. ~" c
#include <linux/platform_device.h>
: C9 p4 w7 j0 |
4 I2 ]0 g: q7 M$ Y. e" o#include <asm/mach-types.h>. _" g Q* z: t5 v' E
#include <asm/mach/arch.h>. F6 A3 [) [) R: A; m, }1 ~9 k
#include <mach/da8xx.h>
, ]. z7 S4 }: _+ f; ~- r#include <mach/mux.h> b& J4 M4 _2 R; e# p# z
/ @5 s3 z; P. g6 w) \* U" G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, y5 r7 n6 ^* h8 p8 ?1 x! Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 Q" Q' Z$ @+ _5 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) I: x8 ~6 ~% i0 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! a: n% g8 u( y3 p( }6 @
6 J& y8 A; ?" U- ?9 ?+ [) y/* assign the tl som board LED-GPIOs*/
' P' o0 W6 [1 t' }: rstatic const short da850_evm_tl_user_led_pins[] = {
5 H$ t; X0 b$ S3 L% l- a /* These pins are definition at <mach/mux.h> file */
" ~9 R9 h7 m6 E( V5 @- z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* I# O" {1 d& U* S% S0 [) u2 ^ -1
( t3 Y. o4 q( \8 G};
/ I" o+ J* [7 q: g
4 X* Z# d' t5 {( e/ S5 U4 ^: z/ lstatic struct gpio_led da850_evm_tl_leds[] = {
# c. S# `: W" M- s+ \( Z" l {
& w n+ j4 b1 {/ k) m; d .active_low = 0,
! s+ ^8 @$ X) S# X .gpio = DA850_USER_LED0,7 ?( q- R1 X3 R. I' J
.name = "user_led0",
( u' `8 I7 }( B' B+ | .default_trigger = "default-on",
& O1 p# j7 D' L, L [' T },; t; B: T2 e5 C6 H5 ^) [
{
! V- e- G" o+ N+ p9 T6 K .active_low = 0,2 s) T( }7 U9 P+ [1 J6 P
.gpio = DA850_USER_LED1,
5 S/ D! Y9 R" _+ b8 \ .name = "user_led1",9 R F7 m! [" A% L5 U# ?" Y! f
.default_trigger = "default-on",
% C6 i9 C, `4 C% k) s },; Y, e; A- y, v7 W* q
{, z" C0 d! D$ M4 H. e+ s3 w6 N+ u9 Q
.active_low = 0,
7 m5 [ A: {. Z2 h7 t6 O .gpio = DA850_USER_LED2,! I& T6 b8 [6 F( e2 f9 T
.name = "user_led2",
5 ^" w. p( l8 m0 V1 d .default_trigger = "default-on",' q2 f' Z4 }" b: N
},
% R4 c6 o6 k6 Z5 j7 R) E3 v {
5 ?5 N. F7 A+ ?; } .active_low = 0,4 R! y, D. Y1 h$ C: E
.gpio = DA850_USER_LED3,
+ }) h3 H. G7 w$ |% F8 j4 h .name = "user_led3",$ Q$ {/ B9 }7 X* M# B$ F2 k
.default_trigger = "default-on",5 y& x g9 t7 E8 H4 W
},
& g6 M/ j& [% O, ~6 N2 w};+ n- G# R" w8 S
, [- s" t; L1 q( O+ Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& l4 V8 E' m: i
.leds = da850_evm_tl_leds,
5 L5 ~4 ]0 Q8 V: G1 f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' _( D0 _, A, }- k
};+ F# f1 s6 o% C6 K: Z
/ a! f# @& h$ t! p! V: [static void led_dev_release(struct device *dev)
9 {2 c5 i6 @2 U{
% y" f, ^! x! H8 J};/ D5 E7 H3 O+ u: u8 x; L9 I P
7 @9 `4 H q8 I9 l
static struct platform_device da850_evm_tl_leds_device = {3 o4 K/ o, Z' C" m
.name = "leds-gpio",# ]. Y6 D* `" e" h+ ~" L
.id = 1,
; B0 T1 m: R- n5 N! w! ~ o .dev = { b Q/ C3 m R: }$ `
.platform_data = &da850_evm_tl_leds_pdata,' N# g; k1 S8 m" U d1 }8 F# S% y
.release = led_dev_release, J/ K% D/ i9 c% v
}
8 |+ D4 e$ k7 K- B0 |# P5 D/ X};* w# J& D: f+ A2 j5 H. p" V
) j$ X% z/ ^0 ^& b. |static int __init led_platform_init(void)
w# U2 l/ W: f& Q( M& y{, p4 j4 u/ `8 _8 ^
int ret;
/ u u: e$ Q1 s2 }' }+ e#if 0
0 |$ P& A* D5 o' d. i* P# S" a ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 S/ S* z/ N$ `* r i$ l if (ret)3 \4 l% ~( o0 A8 Z" c @3 N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") Q6 p) m" k* F+ j6 G: i
"%d\n", ret);
4 V. j) e$ l+ I# D$ u$ x#endif
" x3 C# ?8 J% x8 ~5 b ret = platform_device_register(&da850_evm_tl_leds_device); E. T, {: \# w. \" k' W
if (ret) \' b3 z0 \ K- b
pr_warning("Could not register som GPIO expander LEDS");2 c4 r* \% R( }- I. g) }
else
* U7 z- i: T4 Z6 R printk(KERN_INFO "LED register sucessful!\n");& z+ D$ j' U2 F/ S: X6 V
! D: n5 v3 g4 ~& d" M4 ] return ret;7 l' z! G) S) O$ h- F
}
4 i' W( R3 i0 @* w+ ]8 G. n" D" m u* B' M; C
static void __exit led_platform_exit(void)6 q; G7 V; O: D5 ] X4 t
{
j+ {" K" f/ J5 S1 L platform_device_unregister(&da850_evm_tl_leds_device);
" o# o% a# G: t5 z& C. E0 d( q# R: d$ z9 J O
printk(KERN_INFO "LED unregister!\n");' N: m. ^! s7 k0 _! N; b
}
- s2 `3 _' E* \/ k9 m* ], L/ p, S
module_init(led_platform_init);
4 b* S x$ d& A! P% M: ]module_exit(led_platform_exit);
7 h. \6 S: j1 \) R
8 p! X) V6 _* w' t5 T: G: B( w/ o& VMODULE_DESCRIPTION("Led platform driver");
' } p. ~7 N% A2 h2 vMODULE_AUTHOR("Tronlong");. ~. f8 S/ F8 s/ g
MODULE_LICENSE("GPL");
7 Y' i- _5 U3 n, w! U. C" D- G+ q0 X3 ]! _! P
|
|