|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 T* Z/ v% C8 O7 n% o8 v7 _#include <linux/init.h>
* z9 e' J- W# r( S' }0 a1 [8 O#include <linux/module.h>1 H( @' {( `) W6 {% q; O e" n' L
#include <linux/kernel.h>3 w& a% x' m2 O/ b+ [) K: o
#include <linux/types.h>
' q1 A& A, x% m8 g, @3 Q7 l#include <linux/gpio.h>8 W x5 q( q* y1 A2 E3 D
#include <linux/leds.h>
* L* m1 J) f2 I! d& s+ _#include <linux/platform_device.h>
8 \6 s4 C! @! {4 I6 c
W3 t5 ^& O" E$ J; b#include <asm/mach-types.h>( ~3 f, i. W2 Z6 u
#include <asm/mach/arch.h>& F C0 e0 {5 K" h0 n
#include <mach/da8xx.h>% i7 [3 y4 v( e2 G) g3 F
#include <mach/mux.h>5 m! M2 h/ C" d0 _
, k6 Y O5 y) A/ v1 B% G/ A3 x4 W' h- B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): L& | [- U7 Q( M* i
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 O& H% ~2 t. \7 Z9 O. @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" `8 f' g* C2 [2 \ D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- j3 h. n1 Q' w) v" h
+ ]6 b/ q4 g9 ^% ?/ R
/* assign the tl som board LED-GPIOs*/: ?" D$ B: w) V- Y) B% O! S4 c3 ]
static const short da850_evm_tl_user_led_pins[] = {3 f& v9 }( L d* k! k" ^
/* These pins are definition at <mach/mux.h> file */
% L t2 j. J" V' `) }! ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 e t( v- c2 ]; s -1
8 m- U: J$ G0 ?$ @; G};
+ j! X& Q0 S7 N
# s# |" m e" b0 C( r' cstatic struct gpio_led da850_evm_tl_leds[] = {
5 @* T. k `3 ` {
4 d3 {& w" M/ z, T .active_low = 0,
8 d1 n/ b, d* \# l: ^ .gpio = DA850_USER_LED0,. t. S9 [$ c1 ^9 `. r' _9 H, s, M
.name = "user_led0",) f4 |6 x( P' n; w; m
.default_trigger = "default-on",
) S9 g: s: U9 e5 K2 v+ a6 S4 \ },
3 m/ m. w/ P% r _( `3 Q {0 I6 [& y" O8 _6 X! P9 E5 {
.active_low = 0,) B1 V7 ]+ G$ g5 O
.gpio = DA850_USER_LED1,
, B( p+ Q7 b6 B! b .name = "user_led1",
5 c( W* @4 S, i .default_trigger = "default-on",
; ]" p9 C, R5 v5 U2 l; o: I7 Q },
2 s% v: ^- s5 U {4 |5 ~2 }/ H9 ] p U
.active_low = 0,$ {6 r, q! s) i7 y, X* S4 v3 W- N
.gpio = DA850_USER_LED2,# {8 u) N) ]! i2 f4 j0 _
.name = "user_led2",' v% A+ {5 |, v! M* c! ~$ ~
.default_trigger = "default-on",
( b& K3 B9 ]" M8 P, z: W },; d" p! T% x0 I+ P+ t- A
{
3 u4 B: [5 F& H .active_low = 0,
1 R- ^- U( y6 `- N/ e .gpio = DA850_USER_LED3," K' |; x5 f, b5 |( Y& D" a3 b
.name = "user_led3",
& o. `+ C& p6 c .default_trigger = "default-on",
2 d+ Y2 u7 q2 c2 ^) k: c },4 I4 j8 D% {3 X' v7 ~
};/ \) S' g& K E: N# t4 u. _# T0 \
$ t7 m" }% G6 V( y" B
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 h+ S! S* x* f8 H* f. f5 A7 w
.leds = da850_evm_tl_leds,4 _+ Y4 W$ `3 O% f5 x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ F, i5 v' R u' S/ ~* C9 |
};
" j" C2 T: {1 M, D" Y% x) L0 G8 Y$ _3 T8 o. B7 J6 I0 m4 ~
static void led_dev_release(struct device *dev)
2 W6 f$ j- }2 o1 ~* X! o{% ~6 `1 \. q" H* m
};
' ~& S6 B; W) {/ [3 N" ?( e
% b N1 d' R" J$ e. V% S/ Mstatic struct platform_device da850_evm_tl_leds_device = {! h% Z( g8 g( d' T
.name = "leds-gpio",. r6 l( W ~0 ~7 m6 s% [
.id = 1,
* g4 T3 K3 {+ }; b: g .dev = {
* z9 w7 ?5 n" c# W( m* q$ @3 t: T b .platform_data = &da850_evm_tl_leds_pdata,
8 q9 P0 ?7 o2 m( y( ~7 | .release = led_dev_release,. G, Y1 X& s) a8 X, e0 z$ d5 S
}
0 s4 p( [2 D0 I};! q" D( F/ i& X- V M) J: r
* d N; V* K' F& B: b! B! hstatic int __init led_platform_init(void)
8 u5 A3 D3 n/ F1 Y1 d3 `. q& j{
9 Q5 _6 O8 y: a7 y8 d int ret;0 c" |6 @* p) l8 b" v9 l/ G! e
#if 0- w1 Q& P5 l7 ^7 n8 W" |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 B8 P9 N3 }' H" K5 G
if (ret)# U3 r0 \& x* o0 T. j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 G. {$ _' h* ]9 ~, {
"%d\n", ret);2 x& ^' I+ Q6 J- Z
#endif
) ]- s7 j# t4 r- u% q ret = platform_device_register(&da850_evm_tl_leds_device);% q/ A& C& n2 c( H9 ~2 s# F; S
if (ret)- | c- o$ i! t6 l
pr_warning("Could not register som GPIO expander LEDS");
2 X# f7 r7 L) `- \7 e+ { else* N7 n& u8 s1 I- \6 |6 t
printk(KERN_INFO "LED register sucessful!\n");2 k( f, U; l$ u; b' k
3 U4 B' d- y% N7 N5 y3 O2 ?
return ret;9 j* t, F( w6 d" ~& @* B1 Y0 W6 e+ r
}
1 |+ L4 a$ O1 r: P R8 p! Z& y- V; S d$ ^& n+ a+ u2 ^
static void __exit led_platform_exit(void)
* Q" P8 ]# c" d5 E{
! M8 e! j: ~8 g4 q* S platform_device_unregister(&da850_evm_tl_leds_device);
- ]" W' p; r: l4 R' b% e, P! v* q8 L V3 S! A
printk(KERN_INFO "LED unregister!\n");
# c; D2 c4 ^1 k}/ N' U. a7 S2 G+ U* m7 p/ @( V, P
2 G- ]1 u% q; Y1 O( Zmodule_init(led_platform_init);+ t! [ |7 `( B; g+ h% O) q
module_exit(led_platform_exit);1 s4 n9 s% J; S; i
5 f3 z, i7 \, ?1 D; x( y& |MODULE_DESCRIPTION("Led platform driver");
( h ?3 j B! t! QMODULE_AUTHOR("Tronlong");8 N, h' P$ U( T' a& B
MODULE_LICENSE("GPL");, e7 N5 V+ W3 G! P
- b; w( D/ O u$ z& f. g
|
|