|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, A8 g2 G w9 I8 p! C: u) m( ?
#include <linux/init.h>4 g3 n, n9 u5 Q: A, x$ C. f
#include <linux/module.h>
' b [& ?+ ?, M#include <linux/kernel.h>- e. s3 }# |4 X( B: O- n- V h5 `
#include <linux/types.h>
" V! O7 ], M& U$ f+ c% L#include <linux/gpio.h>0 u- g R( O5 ^1 p( d! ^9 A- E" U7 C
#include <linux/leds.h>2 |, Q v- c* d5 K
#include <linux/platform_device.h>
/ h/ H# v# t# X6 p- M$ z% a) l' Z9 a* x2 ~. o; k9 I" u5 r- B8 _ ]( I
#include <asm/mach-types.h>
2 l$ A7 P$ a3 w/ c8 ` q#include <asm/mach/arch.h>
{( D+ H1 t4 S& v2 Z#include <mach/da8xx.h>/ Q8 }/ W1 i; o6 p, n( |+ ^
#include <mach/mux.h>) K8 P1 ]& ], g) C V( ]7 P3 L$ O) V
( f6 m# r$ @* Q! V6 D) }! h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ D2 N* O, R8 J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! y9 o9 |) |1 ~2 l1 F- [5 d/ U( l6 E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 g# y, v U, _: J4 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 i( V+ b7 O2 U1 V% g0 U- m. e2 e: C9 d/ F! _
/* assign the tl som board LED-GPIOs*/
' c' z$ `- ?& H1 k) z1 Xstatic const short da850_evm_tl_user_led_pins[] = {
* |! J) v% ^2 i/ O /* These pins are definition at <mach/mux.h> file */. V9 B2 d. p9 J% m$ B! }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 y3 x3 h! U5 `' V/ I
-14 t- t6 y2 t. l% W/ ]
};
# c, h9 K& G- O$ ]4 h0 y
8 h; U7 O) x! \3 O estatic struct gpio_led da850_evm_tl_leds[] = {
, c# ?/ ~6 L! }+ p {$ f$ o. a2 R; E" l& a& @
.active_low = 0,7 ?1 h, g) S n( {6 t& P
.gpio = DA850_USER_LED0,& {8 `- p3 o6 o
.name = "user_led0",' [" Y0 m0 x Q0 O
.default_trigger = "default-on",& C [ k3 k5 L2 R, f: X
},5 P2 K. {7 ]- O4 @( q
{, R& n# N% Y- o
.active_low = 0,
7 A, i$ m) N$ [$ ~1 L/ n4 E .gpio = DA850_USER_LED1,
3 P( }' T% y: L$ M( o3 {! q, a .name = "user_led1",: S( w5 i' B" n$ R3 R5 E' A
.default_trigger = "default-on",+ ~2 N. p8 K' N2 g
},
8 d' N+ p4 u2 L9 Z D$ I. v {% s$ @ V( ^, o$ [. H J( \
.active_low = 0,
7 W3 q+ y3 Y9 j8 O$ J4 {5 Z, ^# D .gpio = DA850_USER_LED2,
+ a4 _9 s7 K5 u- X+ O .name = "user_led2",
. S6 g, |9 V [0 s2 Y .default_trigger = "default-on",
: C* d2 B* s# {9 V& D! k },
) j q* n3 ~0 h! i+ ]( f# Z: Z {- r2 Z5 A( T! M2 d7 |+ D
.active_low = 0,
c4 ?( n$ N) v$ ]9 H .gpio = DA850_USER_LED3,
: w) N2 U- |: { .name = "user_led3",
" W, Y, b( \! N5 [! `- i$ V .default_trigger = "default-on",8 v. P" v; `9 X- w3 X
},
; N, T: l, P/ f};
5 D0 p$ `8 `1 o% h! u& f, s( B% F) H$ Z# b# N( W: g; s- G* I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { H4 C8 k7 d! Y
.leds = da850_evm_tl_leds,( V: U b6 e8 i2 V/ ]* C( `; Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* Q& h6 R1 S' z& v& n};
$ z7 L. ^5 F* w: e- B2 c$ B& ?9 }! T" ^5 V; m- X
static void led_dev_release(struct device *dev)
5 G3 t* P+ O. A7 _! z. W& ?{
4 R% b o' `5 G/ W/ S. L};2 D) i% N. @1 E" }/ U
' [$ o- V+ n: o7 Estatic struct platform_device da850_evm_tl_leds_device = {; ~ w# P# ^( K$ [- K
.name = "leds-gpio",
$ R+ j/ R) G( Y7 \( t .id = 1,9 [+ b" V# P7 g: \3 \* P, ?
.dev = {+ ~- i# n# c2 e0 y
.platform_data = &da850_evm_tl_leds_pdata,
3 t' w {7 }% N# `' v& N6 B .release = led_dev_release,
: A2 U! s/ G% p6 X6 U$ W4 W3 c }
7 O7 M8 F) X0 |2 Y$ o};# c7 a l2 E% n% C# I! x$ T
: ?+ s3 b/ T7 m' ?static int __init led_platform_init(void)
' Y7 W; b! j- F4 {# p{( }4 E" K& I& B
int ret;+ G* b+ u$ i( p/ W/ ]% Y" A6 t
#if 0, ]6 i4 C0 S7 Q/ u2 e, t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 M: s. D$ a5 ^. }% o if (ret)& ?; H& @& I& l% O; b
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ \8 e' G7 d) L+ @, K9 ? "%d\n", ret);4 q1 i) S( | J, F7 r2 _, Z
#endif, _3 g9 q! k8 U- W: _/ Q
ret = platform_device_register(&da850_evm_tl_leds_device);) J3 o. \+ j4 N) a3 F' x( q' H
if (ret); ?9 V) W0 N! o: [) b ^
pr_warning("Could not register som GPIO expander LEDS");
# K7 [, V5 J* M. p6 p ]" D else; I) J6 r/ n: N; M y; ~3 Y
printk(KERN_INFO "LED register sucessful!\n");% ~" P& R% [2 \& M2 y7 K2 Z4 G; i
: T6 J+ o( a2 @
return ret;
3 I0 j* N/ Z; }) t( r}+ M# U8 ?( P: w H. ?4 t0 v6 E
; V: P! l7 {, r5 e6 r' L, C/ m" H; J' q
static void __exit led_platform_exit(void)
1 B3 ?/ P; [( h# D3 `{
5 m" C" T- Z3 ?! ~, D platform_device_unregister(&da850_evm_tl_leds_device);
; c- \. }* ^5 i1 {! N! j2 x+ j
, d" T: S+ N* P l9 f7 j2 \# k q printk(KERN_INFO "LED unregister!\n");
5 f9 }) y5 y2 O5 @, W8 X0 K0 u}
( n8 e4 o: d0 G. z$ ?9 n! u
y2 j9 i( i/ Z9 G2 J- [module_init(led_platform_init);
1 p4 [! x4 V& S1 F2 k- c/ d* omodule_exit(led_platform_exit);
0 A4 @' Y5 g* T2 G' x- ] ~1 s- o; @
MODULE_DESCRIPTION("Led platform driver");
2 ?% ~ G4 a/ A9 ?5 M0 u; Y- QMODULE_AUTHOR("Tronlong");1 w- f i1 V" }% U+ e; f2 F7 E% r
MODULE_LICENSE("GPL");0 c# r$ o; m8 D. b k7 t
& I+ Z4 M2 n0 S6 F% \" n; {
|
|