|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 O; B+ r" v3 P) ~' ~8 t#include <linux/init.h>
3 h" p# O/ i% n( Z" q/ c0 ?. a#include <linux/module.h>! d: z3 o9 b/ \5 y
#include <linux/kernel.h>
. ^6 R4 m- t1 g, q7 u#include <linux/types.h>
" i) } i9 l5 R" P+ [& G( c: f#include <linux/gpio.h>
1 m G7 s3 w. D! g7 z#include <linux/leds.h>/ c4 E) `# N8 F( Y; N. T' I
#include <linux/platform_device.h>
- K8 V5 R+ Z+ p q5 @9 t
2 \4 r% L& y& q* h% z( e$ i8 x9 J#include <asm/mach-types.h>! y% d9 k& t! |; L
#include <asm/mach/arch.h>
2 L& [6 J" s! t& }#include <mach/da8xx.h>
+ J1 W* D: J: |#include <mach/mux.h>
0 z, H% Y2 u- Y9 |
; h3 {) q$ A: O" t9 @$ ~8 W9 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, v" Y1 X& P; S2 L# q' i8 q0 y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( ?; H6 z) o# }% z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ G% {1 \0 m: u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 Z. C& f- g& y
4 C. k2 Y1 r# o9 X/* assign the tl som board LED-GPIOs*/
3 c! u8 L, ]& Y# i. V' cstatic const short da850_evm_tl_user_led_pins[] = {
, b! ]# O( V" q G /* These pins are definition at <mach/mux.h> file */7 A/ M" q2 n7 M( G) |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 @: i4 x5 ~/ h6 ^$ L# n
-1
6 u" L7 S \* G, y" m};
% u: r7 D9 u3 r' t% b7 b/ L/ t B* p9 ?- ]' ~5 `8 R5 B
static struct gpio_led da850_evm_tl_leds[] = {; M+ E4 [+ Z3 S
{
M3 x1 ?. u$ f; } s' k# R4 f .active_low = 0,4 t( a2 Y# f3 z3 h+ |
.gpio = DA850_USER_LED0,- x# @, u9 J' s1 R5 m. t
.name = "user_led0",* T. n) B m9 M! b
.default_trigger = "default-on",% b: J' k- \1 C2 H/ g# @+ _
},6 ?( m, ?, }' \* E3 M
{4 ^# s: ?0 d2 u9 b
.active_low = 0,
$ V( B" ~3 |% r) g9 X: ? .gpio = DA850_USER_LED1,+ N# s6 z! G$ _5 H- l
.name = "user_led1",* M! ^* d& [1 N3 s$ y' x
.default_trigger = "default-on",
/ A/ `# t! {9 n' q* X a },% }3 g, I5 z7 ] X) g
{( t9 @/ K0 F' G! A! a) E9 Y6 J
.active_low = 0,
' w) P: M5 m) } U* L .gpio = DA850_USER_LED2,
$ j/ E G( w b* o1 t- n0 e; l .name = "user_led2",9 M' b4 k/ m- d; X1 B
.default_trigger = "default-on",; a1 M- F- X q9 m7 r1 \
},
0 p7 `" J9 A- Y% m+ s4 j$ M {0 ?7 ^4 P# F" k7 g3 ?3 ]) b% a
.active_low = 0,
- C/ D2 s$ E7 i' L .gpio = DA850_USER_LED3,5 }8 ~+ I: D; C3 Y6 K' D
.name = "user_led3",
+ d. d/ n6 ?: k! t .default_trigger = "default-on",8 p: l+ `+ ]- L w) P6 q4 c
},
" ]$ R8 w8 [( p) ^. `};3 V2 z$ a8 o& J; z+ x- R
: K+ d8 S4 ]+ H3 X" f" p7 f4 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! }1 H; g5 o4 `/ b9 n: z
.leds = da850_evm_tl_leds,
H4 o6 U8 o# t, z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" I+ W5 Y% t6 B& [. m};3 s4 i( j8 T9 Z+ z; k& S5 Q
6 k! q& _( P' w bstatic void led_dev_release(struct device *dev): s0 u( {( V1 H; c8 e( X# I# b
{
! ?3 c) q6 @/ ~/ m$ G};
6 u, V U( y4 m2 f( ~& P5 M. B& g7 R H# m/ H' n2 Q1 M
static struct platform_device da850_evm_tl_leds_device = {
S: L" R3 p2 E" N! Z& r .name = "leds-gpio",
- @$ ~1 ?1 j4 s .id = 1,
6 i5 g( b) @+ D4 N( W! V .dev = {0 J7 h& z! {$ ~; i( B5 d
.platform_data = &da850_evm_tl_leds_pdata,0 B% C- v5 E& ~& N1 u
.release = led_dev_release,2 r8 |3 t# u- g- d8 G: F
}3 G! \! r2 K# x$ X) e, `
};
6 D9 X6 o* }. H- c e" P, X8 `( G
static int __init led_platform_init(void)1 Y: c W- v: @
{
: _! @9 _" ]1 B int ret;) i" Z b8 e2 Q% D0 I
#if 0
# l7 L* X! x+ P' ~* @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. L' l; ?( ]% ?! V5 S if (ret)% H2 y8 P+ J! Q' ?! A0 }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 e0 A/ ~$ W4 b "%d\n", ret);" F; L3 [6 [7 \2 s" Y: u1 {
#endif L$ T2 B; p& o
ret = platform_device_register(&da850_evm_tl_leds_device);
/ _2 j5 e( Z' z, ~% G if (ret)/ z! G6 I3 Q3 T+ B0 y
pr_warning("Could not register som GPIO expander LEDS");) s* Q* V. Z- g8 X0 M" S
else
' M2 }7 e$ L4 c& j; _+ d& _ o printk(KERN_INFO "LED register sucessful!\n");
) {& @, j }* b0 p8 ^# e& h5 A; R# L4 W" {) o
return ret;
4 H, J1 L% Y) o" _. P U i$ t' b}
; j- F4 }/ e6 y! J; N# N* M# h' H
static void __exit led_platform_exit(void)* D% `& U2 d3 L& e6 g
{; E+ W+ `8 D, T* p5 a
platform_device_unregister(&da850_evm_tl_leds_device);5 O( g$ K* t' X# ~
$ |) c3 h: ?# i) ~/ J' { printk(KERN_INFO "LED unregister!\n");
R, o+ {1 f9 a$ p: c: w/ ^}( a5 K6 ~. O! G5 `) l
. @. U8 N/ H; B* D( u
module_init(led_platform_init);5 ?0 \! g2 S& a( U
module_exit(led_platform_exit);
0 Z0 \, |: O) a% |$ O5 T
/ N8 @. s6 X9 x: l5 ?0 }+ wMODULE_DESCRIPTION("Led platform driver");- C1 I5 r2 g8 l! G4 T+ P. V
MODULE_AUTHOR("Tronlong");* _* W* e* r S1 z" }& z
MODULE_LICENSE("GPL");' n0 v! V. d6 m
3 b( b: ~0 |4 M5 u$ l' l: e3 u# e |
|