|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 R3 _3 b& r! k. j
#include <linux/init.h>
6 Q. I1 M2 Y+ [$ e& o* N#include <linux/module.h>3 V' }# N3 z4 j) a) @! T: P: W
#include <linux/kernel.h>
% E4 x" Q5 a6 {5 [& A, b, N#include <linux/types.h>9 B( Y- S: l* Z( ~! y/ i
#include <linux/gpio.h>6 U1 R* t, k Y$ b- U2 d7 I6 Q7 w
#include <linux/leds.h>, j$ C& C. f8 Y' d
#include <linux/platform_device.h>
2 R- e3 L h# t: c" t0 r3 K
! c4 S x& B \ K3 }! r$ x& O1 d3 T#include <asm/mach-types.h>
& x8 ^8 Z& D0 c3 i% K#include <asm/mach/arch.h>
. u" _7 q8 m0 ]#include <mach/da8xx.h>8 M/ p: {2 O/ f6 [) W# ]
#include <mach/mux.h>
1 B' b% E3 X. w6 a& F" ~
/ w5 l; N' s1 a0 {, e" n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ n+ v2 X8 n* _1 ]
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: N: Z' R+ T. H5 u% `! Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( N2 M/ [$ S9 U0 \4 t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ A% b" r( G! a/ s
1 D- i' B1 i o5 o3 u/* assign the tl som board LED-GPIOs*/
8 `/ C5 k& b: Pstatic const short da850_evm_tl_user_led_pins[] = {4 |' v, t2 H7 G2 d/ |
/* These pins are definition at <mach/mux.h> file */. e4 o+ I r7 I3 N$ I* k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ R; X9 T5 E; e7 n2 [
-11 U7 j6 k/ t# M. o4 Y" j
};
; G3 ^+ u" N( J( J
$ W6 @$ B, d2 y7 R: A* Istatic struct gpio_led da850_evm_tl_leds[] = {
& }: C; Q. e7 ~+ ^3 E {
5 p$ w2 Z# }" q( n5 w .active_low = 0,& R% d: K& {% x
.gpio = DA850_USER_LED0,
* l+ I# K% u) t( h) d) u" L# D .name = "user_led0",( `+ x; G. a' s/ D7 c i
.default_trigger = "default-on",
: G2 `. [, ]7 { },& B, E) ?- b* Q7 k
{
2 B+ e" y9 }2 b/ L .active_low = 0,$ m* }- T* g9 }) E0 ?
.gpio = DA850_USER_LED1,& E* b% Q$ q/ T4 Q) ^9 {0 W5 T% Y9 O
.name = "user_led1"," ^, m% {, c' D# |. u
.default_trigger = "default-on",
% H0 K3 E# L5 }. V$ V },' F- ?; @' y- ?
{# _# Q. C# m$ ^3 A% [+ K8 o: U
.active_low = 0,& p- n* \1 q* r- U/ x# Z% `1 r# v
.gpio = DA850_USER_LED2,
7 H2 v: k0 g$ c# ] .name = "user_led2",
8 m4 j! V6 Y; ^( ~# H3 s .default_trigger = "default-on",
% l( u9 B! S! Y3 ]9 X },
2 g4 y1 y: D. H* F# m {- E0 S+ v! \, ~ P" \' x5 [6 ^7 |
.active_low = 0,$ H) L1 K( W. }# P5 @9 A
.gpio = DA850_USER_LED3,
. J+ K0 W7 C0 I, H9 w0 j& h .name = "user_led3",
/ }$ [. m- g/ q6 F+ X3 o .default_trigger = "default-on",
- H: @ _* x! ~ },
3 k) A0 {8 S5 E, V' v3 y: o3 _# u+ j};
( I. y' j. u/ e* R
: o/ q& ^6 O' H( Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, U" P1 W$ \* G; L# _ .leds = da850_evm_tl_leds,
. i4 w7 D$ D, B) Q5 X( u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 I- E2 W) M4 C! k) |3 ?% ^3 D' G};: W) c* Q" v8 L, f. x9 H
+ d6 K; Y, ~( c( e* y& ?$ ustatic void led_dev_release(struct device *dev). B" a+ f5 A( e- e5 z% l( l
{+ M. E8 D" w- U* y" Q# D2 y1 x
};" s; t- s0 G6 c
( l2 D! f* X. X1 ^( Z
static struct platform_device da850_evm_tl_leds_device = {
# p. |5 _0 z# O% h8 f, L+ z .name = "leds-gpio",
. B; U& B: x. l* S6 A& i) t8 z .id = 1,5 Q8 E8 \& L7 w% k( N3 V
.dev = {5 P" s% ^: f# g' R
.platform_data = &da850_evm_tl_leds_pdata,! d* Y5 R" |5 |; h9 r2 Y
.release = led_dev_release,3 G( z" x; S1 K1 Z3 K; N; ?
}! L+ Y2 g/ k p% M4 t0 t$ t' a
};
; t$ u. k$ H" _. J# A0 l2 D/ r( T* c+ a
static int __init led_platform_init(void)
3 D: Y7 M2 N5 f1 T" a{
- F0 _$ `, G9 p/ l int ret;
( N' B) i! y- m) X. t1 I, i#if 0
9 j [5 P8 @0 U* ?$ ^; b- r6 k7 G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 S6 Q: q$ l+ \& R' q8 q2 e1 t. ] if (ret)& g# H: W9 _6 b9 Z# \! K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 D) q( R9 i- z! @5 ~ "%d\n", ret);2 U# L2 C' J& e. _
#endif
' B) b4 s4 N r; ^ ret = platform_device_register(&da850_evm_tl_leds_device);
, E6 M, ?( V x# a- x8 {2 G& M! x if (ret)
: l6 `" h5 F" e8 P0 e1 \ pr_warning("Could not register som GPIO expander LEDS");5 N) Z( p0 k2 t# \* ^
else
9 ^1 v4 d7 E$ n printk(KERN_INFO "LED register sucessful!\n");
, G5 x6 O' e2 e4 s
5 A) F) [! v& ^- a5 E return ret;
0 s& R9 }) {. i9 e( }! P}
. w& t: [* U( E: q
9 F$ g) t: K+ P( V% fstatic void __exit led_platform_exit(void)4 n% L9 E( o9 ] E
{
- G1 y0 M k" Q4 a; x# F. w# a platform_device_unregister(&da850_evm_tl_leds_device);, y# @ g& F' c) ^8 t0 @
: S6 \6 R t; ?( d& R# K4 q printk(KERN_INFO "LED unregister!\n");
) K# N/ |8 ?; \ `, l" W! F0 |5 D}0 E+ \% ]; A1 l- f$ Q2 U" y. ]
# F- C, {% q7 ]module_init(led_platform_init); n0 g6 A! n7 L8 B m& c
module_exit(led_platform_exit);. u5 L& c a! }
; f- Y( M9 l. ]$ Q5 ]MODULE_DESCRIPTION("Led platform driver");
* i6 v$ ]- a# R8 Y/ dMODULE_AUTHOR("Tronlong");
8 U3 |) [ S! D& O8 ~! T$ wMODULE_LICENSE("GPL");% M2 w& y2 G( h0 s: Z
& D& E$ E* B$ p6 P
|
|