|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 V* Z! |& {$ \3 ?& d! t#include <linux/init.h>) @, @; ? q7 L( l# V
#include <linux/module.h>. K& r( x# w- X& V7 ?- D8 Q
#include <linux/kernel.h> C7 c& M: E1 T% n& q6 _ }
#include <linux/types.h>
+ S+ B# U) {0 f$ Z/ m#include <linux/gpio.h>
- m% q |; E3 S# `9 U4 T0 g#include <linux/leds.h>, ?7 Z8 f2 L. _# V \/ M
#include <linux/platform_device.h>. {6 i0 ` j4 H+ R1 @8 X, f, P/ N
8 w0 `: x# m5 u#include <asm/mach-types.h>
( @8 e/ o; S3 `0 I. _#include <asm/mach/arch.h>3 {) H( e8 h3 m. ]* K$ c
#include <mach/da8xx.h>
# Q% f3 E, x. Q. z" o6 Y#include <mach/mux.h>
7 c k- f# V1 }0 i; l9 k6 m, S f- |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 z- d) ?) J; D/ K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) P* i7 n) ]8 }#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' C* L- }8 g9 k4 S+ v* ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 {* d$ ^; @8 |/ i% h9 Z1 k: [; h; v% \
/* assign the tl som board LED-GPIOs*/
) f0 C0 a( M$ `! Q2 Y% vstatic const short da850_evm_tl_user_led_pins[] = {
4 @% C @( I6 m /* These pins are definition at <mach/mux.h> file */
2 G- E( R5 m- m: g+ F N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 s+ p( E8 g6 ]! s) ~
-1- P/ d0 o. y2 n' Z
};3 i, v0 |* y) _( w
a* L4 z: w- `( m- L4 zstatic struct gpio_led da850_evm_tl_leds[] = {
6 _$ j5 ?+ ^9 I% |! q {
8 P! q4 }6 P" I; V7 j .active_low = 0,
4 w1 S7 {; w0 n. W( o .gpio = DA850_USER_LED0,. q+ C& x5 j* |" k; r
.name = "user_led0",
8 p$ Q0 a6 S; ^& ?- a2 ? .default_trigger = "default-on", P4 Y. H- t' A. A$ r, t5 _
},
/ X5 {, E8 L- E. p- s {
. S! i9 T$ n% J2 c# U .active_low = 0,
$ Y1 y# B9 g% i7 i9 T .gpio = DA850_USER_LED1,$ i5 M; }5 y5 L4 |' x* L) c0 |
.name = "user_led1",
3 H2 l* ~# {5 e .default_trigger = "default-on",
" h" H& T. c8 B3 ` },
9 e. V% ~' `7 y4 G4 |0 H# A {8 S/ l' q! V; f% J b
.active_low = 0,
1 S6 p h: Z8 r/ \7 N | .gpio = DA850_USER_LED2,3 j# }. ~5 G8 @0 e+ g9 L
.name = "user_led2",
) T. g) v h# ?1 a* n$ ]1 G1 j .default_trigger = "default-on",
) l, g6 ]; f8 i/ }( s3 P },
$ A& ^- x; q8 ^ {
: j3 \4 L1 T. }1 x2 x8 k9 ^, A5 W8 P .active_low = 0, E( ^ y9 r1 W: Q x
.gpio = DA850_USER_LED3,
7 U8 _. {+ I2 L( m' I2 B .name = "user_led3",; z8 E) X6 y9 v
.default_trigger = "default-on",
0 x! |' z! f2 a7 O },! Z3 |& ]( G. [
};' Y. G9 A& v; c2 b
3 b& m; R- ^( S) P* n3 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 I1 Z2 q. o3 d
.leds = da850_evm_tl_leds,0 ]0 @" p5 M+ ~! G! Q& H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( F4 M- y1 a8 K" S# _7 o) ]};! N/ W! j8 Q7 W
4 G6 o! Y, g( m& N9 Y6 ^& Q" c
static void led_dev_release(struct device *dev)
% I5 e9 U. M& J- u1 @7 o) L: i4 O{( E! B. c+ I: O; K& A+ F( {
};9 r0 v+ F. |# F2 B# M3 @
, \; }# X3 \; e+ g ~: }' D: E. ^static struct platform_device da850_evm_tl_leds_device = {
, m+ D$ S7 S" H .name = "leds-gpio",0 m$ v4 x" q) u, J
.id = 1,( r3 [/ J. V3 k+ ?7 U/ q
.dev = {# G# F1 {# Q) ]( H$ Q1 ^2 Q3 U
.platform_data = &da850_evm_tl_leds_pdata,. v4 |3 v1 K, E* y1 l
.release = led_dev_release,
7 s, l" u. }7 I d0 j) {4 M3 Y" w }) w$ Y* V$ V o5 e: P. E8 N
};
& K/ |8 s/ y$ m3 I- p
+ V2 ]' l9 O E0 D. pstatic int __init led_platform_init(void); ?+ J2 v6 X2 G- t5 s
{
5 y4 v" q9 |7 z- |' C7 e int ret;! `6 u6 p$ J, t5 [
#if 0$ F# M' ?$ d: b$ l% ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ c( v8 m7 s9 F% E* a if (ret)9 M9 U: L: f* E+ l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: D$ h L. b: S# R1 L6 i "%d\n", ret);. p' ?" w7 z# f" ^0 V
#endif
' _. q; K& Z" G+ W! C ret = platform_device_register(&da850_evm_tl_leds_device);
1 i( g1 B ?+ H, ~ if (ret)& f* C3 V1 ` L0 X/ x8 Z! ~: k
pr_warning("Could not register som GPIO expander LEDS");
+ }- ] {! x Y( B: R* W; k else0 D& n9 Z0 }8 G/ j! z
printk(KERN_INFO "LED register sucessful!\n");
& S& q; F( ?6 o8 c. [
8 h; z. d, ^; b% ~, n6 e0 |7 w return ret;
% I$ U+ n5 i6 }$ c# G}
, J. B& ]! K6 p; }" X" E2 }: L) _9 R& t. q# n# H8 }
static void __exit led_platform_exit(void)0 N l3 ~( B1 A. E* A$ H5 c, Z+ I w
{, ^( L" t+ o" Q4 w* l( D
platform_device_unregister(&da850_evm_tl_leds_device);
2 O! g+ a; _( o0 O. n R2 |+ l5 c
9 P9 c' ?3 J2 G# u; h. \% g/ E printk(KERN_INFO "LED unregister!\n");3 L4 x& C' r9 ^* s- Y1 {
}
8 D- W- c7 y! V+ ]
8 b$ A% n1 [$ `) l5 {module_init(led_platform_init);
! R" O# q7 Q3 x# smodule_exit(led_platform_exit);
3 v. @8 w8 I: A9 }, G# I5 X0 Z5 _3 G5 O9 b5 P! [6 \& K
MODULE_DESCRIPTION("Led platform driver");
' a f; W' f1 GMODULE_AUTHOR("Tronlong");" @$ \# z* _# r' v; c4 \
MODULE_LICENSE("GPL");; v' I9 Z" i! L( y2 ^4 B# N
! R) T6 Z5 g- W' Q! I S7 G6 q
|
|