|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- T% O6 H, k/ r5 s, \; W
#include <linux/init.h># Y0 q8 Q0 k0 x, _4 {
#include <linux/module.h>
& i+ H0 t _. C) _( s( `" n#include <linux/kernel.h>
]7 O5 n; l7 L+ M5 e; V#include <linux/types.h>
5 ]6 X/ ~. n s5 x' _#include <linux/gpio.h>
! w/ C. d$ y7 |5 N- R! a#include <linux/leds.h>" Z6 E/ Y, F' `; X& z" d. i9 p
#include <linux/platform_device.h>
5 ^0 t$ t9 e% E. x! e' }4 Y! F4 ?: w- f, H, ]2 Q
#include <asm/mach-types.h>& ]+ |& g) D, f- q, ?, i
#include <asm/mach/arch.h>* n J0 W }3 ^# a
#include <mach/da8xx.h>4 \( r8 N! S1 {1 u
#include <mach/mux.h>
# U5 J0 f8 g: @& G- B; d( K! W( Y* u0 K! }0 ?3 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): j3 O9 Z6 I4 [5 V8 |7 [# ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" c6 V4 ~& r8 a9 R* n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 |2 r. M) i0 s+ C* g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' E+ {/ M* m4 T
" I: s' {) f4 P0 x/ d7 c9 \. o3 \3 \" {
/* assign the tl som board LED-GPIOs*/
2 o& H" r# J3 |; }* fstatic const short da850_evm_tl_user_led_pins[] = {
% F- s* {+ F ] ]1 R /* These pins are definition at <mach/mux.h> file */
7 w, z1 [# ?; W7 l" G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! e a# E& |$ C3 \; V -18 |- j' [4 R) [4 G' y+ k- K8 M
};8 r& k9 f1 V( J' w! y
; t- c! S5 f) a) `+ s \* Nstatic struct gpio_led da850_evm_tl_leds[] = {& @) R, w) K/ A: L" J
{
) |2 d, b: @ _ .active_low = 0,
4 i% M, o5 P! c' ]/ r .gpio = DA850_USER_LED0,$ @6 S/ b/ r9 a" }$ R% q W- i5 H
.name = "user_led0",
. V5 f: u8 Y# R+ g .default_trigger = "default-on",3 _( q" D4 t$ a6 o7 u9 m
},0 W9 h$ z0 l+ A. c
{2 V1 u3 ^8 h# n7 F; [* V& r
.active_low = 0,. m. _' J/ K* T- _
.gpio = DA850_USER_LED1,
5 z' Q0 O0 E/ b, T. t$ _2 b0 | .name = "user_led1",
2 w2 C& W. N4 h4 X+ a .default_trigger = "default-on",
: t7 a' c* R8 d },
+ N7 d- o7 i7 U# R {
C' ^& M+ i, X& u .active_low = 0,
4 M+ x' N6 a% w9 K" x3 I .gpio = DA850_USER_LED2,
$ M6 J4 \8 D( |7 r1 y% V .name = "user_led2",
8 R# \! Q: @- h' @4 ? .default_trigger = "default-on",
5 D, r" L. f% t. x ]- D k* d9 z },
( ^1 B" k$ U0 h0 Q9 @7 C2 z {/ o5 G; Z3 k9 V+ T% g6 e
.active_low = 0,3 E& u* C. y/ d2 |3 ^7 e
.gpio = DA850_USER_LED3,
) r0 I/ T$ H- c .name = "user_led3",! h1 Q K/ _1 d, Q
.default_trigger = "default-on",
0 |, n4 T+ v L5 d% ] },
6 g5 c/ e, M' m+ u1 H/ c1 a2 b};! Z$ Q9 f& R! h. Y9 ^
% y/ Z6 C( Y. ~% cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 _7 J7 G2 W; C& K% U+ p7 ? .leds = da850_evm_tl_leds,
/ I' G3 X0 R2 X' ~ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% M6 T: A% v5 ` K/ i
};
" e% p! y( T( |0 ]- z. r1 p- }' o# E' R* Y' J: M2 g
static void led_dev_release(struct device *dev)4 ?" m+ s6 u9 T) t; n8 H
{
# g3 T/ G( p. T- l};
* k1 N, s; l. P2 N' W8 M2 X4 A
$ ?. x3 e" J+ Z% T* Z, v' {* Nstatic struct platform_device da850_evm_tl_leds_device = {- g6 C% D) a& j+ _1 m# }
.name = "leds-gpio",
$ m& T4 T* R; }9 A! U .id = 1,
! A5 ]/ _) ~- t+ L& ~ .dev = {
/ T) q4 z+ z$ k. N .platform_data = &da850_evm_tl_leds_pdata,
& F5 \ A3 A% [5 u8 f! R/ @ .release = led_dev_release,, U5 i( Q( n4 N7 N
}
( b( W4 g7 a; G m/ I# f9 r};
6 o. c( p) F& ^7 @7 C9 w1 S: q
2 T2 ?" _2 c7 r5 a$ Xstatic int __init led_platform_init(void)
8 k; G4 P0 e+ D# _{
2 v' S: _8 u+ y4 H0 r6 f int ret;& p, O3 k# F; }" K, @- q# P
#if 0. [2 b8 t% `; t, |% ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* s+ u0 x; \2 `% s* M if (ret)
9 _# m5 X4 ^& c8 N! G' A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
X8 S6 M# P Q; `) q "%d\n", ret);1 y" _% ~' n/ |% G1 ?: B' d1 N
#endif6 u, N- v+ d# w- [
ret = platform_device_register(&da850_evm_tl_leds_device);: p, ^. C8 Q) V" }
if (ret)& Z* t6 T0 K5 t5 U# f+ ^
pr_warning("Could not register som GPIO expander LEDS");
+ c7 ^ u6 }3 N, N1 G" N6 V' K+ G else) U0 c! u6 Q' t- h$ N5 K% q
printk(KERN_INFO "LED register sucessful!\n");
f9 _6 \* w3 |0 V/ n& v3 l6 s
" p$ b- `5 v6 D' T' c! n return ret;# d9 O. ?0 u- v/ M- D: b
}" B+ ^5 }; h6 N( E$ L
4 s8 [8 N9 T. m9 @* @+ Dstatic void __exit led_platform_exit(void)
4 D: S b- Y& r" V( g t, G{
8 T- ^" f# {- E; Z0 x+ o$ J. o( O platform_device_unregister(&da850_evm_tl_leds_device);( H2 U g( ^$ s" R
+ p' e6 O4 Y2 c6 N
printk(KERN_INFO "LED unregister!\n");
^3 J; b9 K9 s4 j* {( U/ D}. L+ p4 l& |# z2 Q4 I8 L* E+ M1 G" y
' k5 a' H; Q9 Y V) rmodule_init(led_platform_init);) S8 [9 x9 Y- a9 e. r
module_exit(led_platform_exit);3 j& G+ v W$ D% F! _
L M3 t# ~- H1 \- |MODULE_DESCRIPTION("Led platform driver");2 P3 _( d( H3 N1 ?' \. x% m3 ~8 e
MODULE_AUTHOR("Tronlong");$ \; d% m& F$ b% O1 j; ^3 w7 G
MODULE_LICENSE("GPL");" j- p! }# y" z$ K; S3 _# f" {
} W+ G2 ?1 Z5 q! f4 V |
|