|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- ^& O! j c u6 v
#include <linux/init.h>
' p' U% e( D6 j1 O( E#include <linux/module.h>
- ~: w, ]; g# e1 ?" r) `4 n#include <linux/kernel.h>
. L6 o* s6 k# X#include <linux/types.h>
+ b Z2 x" `# r" P. j" t( }0 K1 Y#include <linux/gpio.h>3 W/ N" k4 ^- g
#include <linux/leds.h>0 F g, r: t X+ Y( G) a. L
#include <linux/platform_device.h>7 i8 @ i; T/ s$ L$ M+ F- F
: t, Q; D) t7 A$ b) V
#include <asm/mach-types.h>
( l% u* f/ r3 s#include <asm/mach/arch.h>
$ b, _+ ~; {4 ~; F- P- \7 T#include <mach/da8xx.h>
6 N/ x/ p9 d- k" Z#include <mach/mux.h>
1 l. `; i. h( ~0 [7 t# j* z4 t$ G
% _9 b \. l+ Q" o9 d) R) @3 a- Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! P! ]# B2 ~0 V3 H) M4 [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ ?( a2 N8 S3 p% O2 d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ [, m. o+ N" m1 ~#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& O% W9 o+ K; M+ ^, e
6 M$ c8 |9 h( _/ H, Y/ W/* assign the tl som board LED-GPIOs*/
6 c/ z8 ]; x3 w$ g% ]- c6 |static const short da850_evm_tl_user_led_pins[] = {
/ g3 P" }2 {+ J+ i3 ? /* These pins are definition at <mach/mux.h> file */- l/ h7 c- D6 @ z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& p) b- r3 R( W5 e4 l0 P9 M -1' F9 F7 K# D' H3 C
};$ Z3 S! R, Q6 ?. T% L& I( j
" P+ @6 h9 m) p0 W% d
static struct gpio_led da850_evm_tl_leds[] = {
3 L" X' ]' A4 S3 I% h3 r {
l! P5 T# t% ~ .active_low = 0,
' n, k3 g! p! S4 d8 n, a .gpio = DA850_USER_LED0,0 e$ O9 ]9 s+ K; K" ]
.name = "user_led0",
; I7 S$ X% L3 i3 V3 o! T .default_trigger = "default-on",
" I! u8 I" P2 ]5 H0 j4 J; V, m' X },
6 M/ X- D3 G# Y( n7 ` {
, D2 \. t- @& v! d; s: G# r .active_low = 0,
- H/ A. w/ l' q8 E# `0 t .gpio = DA850_USER_LED1,5 L+ }) u1 s1 l! H; B- u# g
.name = "user_led1",! s! D& L8 B; y3 c* B6 f8 U4 k. c
.default_trigger = "default-on",
( n2 V2 X! S3 C$ H9 Y3 [ },
) a _- L( T* J# [# m' g {
( t8 V& O, k& [' E- O1 k .active_low = 0,9 p6 U U8 k7 m8 n( A3 a2 p) G) \) N0 ]
.gpio = DA850_USER_LED2,
L, a+ N. N" Z6 g! Z& F+ A) g .name = "user_led2",5 A t6 E- s0 b1 a9 X
.default_trigger = "default-on",0 }+ O+ |$ V0 B- u
},! i% p; ]% s( \! ]8 Y" Q
{
) b* V% |9 o! o5 a# q .active_low = 0,0 y! I% P- b" @* z1 j
.gpio = DA850_USER_LED3,+ x* Y/ q2 D2 [4 t. I$ c
.name = "user_led3",, f0 I, | Q2 u7 d* L5 C( X
.default_trigger = "default-on",7 S/ y$ }$ _4 G! c6 {
},: H7 x+ @/ }/ \: o+ E
};
* Q% H9 i" C% m! }6 A6 u$ U; O# G, R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- @' M9 I5 ], S- F
.leds = da850_evm_tl_leds,
" O# b+ Z/ D8 X7 i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- I$ h, d \) W" `8 w% m+ v$ U/ M
};
+ p; d' J: Q0 _6 V# h
* ?8 s' Y" s( R1 T2 n' Z$ r: @; Wstatic void led_dev_release(struct device *dev)( s" J: S$ G9 }& j9 K
{
& P; f" H1 i# ^};$ u+ W. r o# }8 i: v4 i
* `4 }; t: }$ Tstatic struct platform_device da850_evm_tl_leds_device = {( Z" N+ u* F( c
.name = "leds-gpio",
* O# [" x' q7 l/ H: k3 \1 M" y .id = 1,1 R& x" t3 p) o F2 s8 [. v
.dev = {
! n2 E* a% ~) P& Q5 A3 `' X .platform_data = &da850_evm_tl_leds_pdata,5 A0 v( w# T( E7 l( o3 I+ g
.release = led_dev_release,
4 z4 j7 v8 @5 ` }& U& s0 c; v& ~ ]
};
) m; p+ k" d" ]- f3 J0 M3 ^7 s- }
$ z0 Z0 k% B1 p3 F# q+ h bstatic int __init led_platform_init(void)+ c; _( S' K% C
{ T$ m' q& T# Q+ x/ |9 Q; V8 g; K% V
int ret;
4 u0 Z, b, \# `- G6 ^0 f#if 0* }+ x W- h( O9 ^) Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ e6 W# U& ^8 X8 a% L# c8 ? if (ret)
( ]% w; s1 k* m- l+ }; L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ k; M( j+ v, f, {2 i "%d\n", ret);' F- r& v. T& g! n$ H x' L
#endif
' U3 O, f# O3 i# F$ T: s- | ret = platform_device_register(&da850_evm_tl_leds_device);- O( S4 p8 \& V# W9 }7 ?8 ?
if (ret)% l5 _7 s: w, C/ p+ O( w! _! C- u
pr_warning("Could not register som GPIO expander LEDS");* F; o! j/ ^3 S% B
else
R! c6 v* l6 k5 J printk(KERN_INFO "LED register sucessful!\n");
( G+ H7 r, x0 ?2 ^# d) | ?
! |+ @! f8 z7 l" u return ret;
5 B r+ x6 @- Z5 H6 ^: E+ v* R+ N}1 y: ~- p0 l2 }2 n
$ ]+ X0 F* @$ Xstatic void __exit led_platform_exit(void)
, `- d4 \$ K4 B$ ]- x; E( S: g{
5 T( s( N" t% A platform_device_unregister(&da850_evm_tl_leds_device);4 X0 }. h0 M, Z! w4 s# @
/ g" V3 p N9 ^3 R
printk(KERN_INFO "LED unregister!\n");, @; D' j! O0 o$ E0 B6 L
}' \) M! a2 \+ U& W9 i
7 E" I! R2 e0 i9 q& }, c# ]
module_init(led_platform_init);
0 u7 `- s" U3 R" Vmodule_exit(led_platform_exit);% c G9 w/ i4 s
8 m+ k, o7 q5 ?- cMODULE_DESCRIPTION("Led platform driver");
0 i" E7 i2 S$ K) b- R6 \1 sMODULE_AUTHOR("Tronlong");
" z6 y9 r8 E) h* G, C$ }# T: V" V0 CMODULE_LICENSE("GPL");0 {& d& Z* }% l6 N* g+ {8 U6 n
- c+ x9 L" l& T! m' N/ S( N
|
|