|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 c- u7 b# L( N S8 z
#include <linux/init.h># y- m0 L A a0 v8 c+ E1 \
#include <linux/module.h>. y9 T5 [* ~/ M! g
#include <linux/kernel.h>
0 t ~- H0 Q' h5 X3 J$ g#include <linux/types.h>
" Z- W$ k6 ]# Z: g#include <linux/gpio.h>
1 H- T( T# E6 e# U, j# Z#include <linux/leds.h>' D! ^- S9 [! u5 Q9 s
#include <linux/platform_device.h>
+ ?5 L8 k' Y$ a+ T7 c: s( D4 l
8 {6 U4 h/ R8 |! K7 L#include <asm/mach-types.h>( M% [! h$ @0 r0 Y/ ]0 ]9 d( q! a
#include <asm/mach/arch.h>
/ A6 | G9 R D2 Y#include <mach/da8xx.h>
* X# F0 f3 x: [ w4 ~#include <mach/mux.h>
% d2 ~3 T" l2 i5 c2 f- U/ E4 ?$ [$ H. n0 p5 o8 C5 r" a& ? E E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 S, g, ?2 k4 N1 f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* o1 h7 a' F0 H% h. P3 T/ o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ }' }0 a0 P) s3 A9 Q0 L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); G3 d1 M9 Q6 U' \
' q, R8 Q6 Z$ U; T
/* assign the tl som board LED-GPIOs*/3 D* w! w* E! O2 J# V
static const short da850_evm_tl_user_led_pins[] = {) Q9 A9 _$ J( z# V
/* These pins are definition at <mach/mux.h> file */7 b" p2 m# }& D+ G) x- t& _1 I6 u) L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 K4 Y+ J- m2 T( |0 i7 Y
-1
% @1 B( l8 w; x5 n n3 c};+ F# g. d) Y. i$ t& a9 J* O9 P2 y
" M' T. c6 Z ?0 u* U% O% }static struct gpio_led da850_evm_tl_leds[] = {& g" U7 a$ a' ^1 w* t6 \
{* u6 b2 Z/ J; [/ u' s) Z& p
.active_low = 0,* ^- p" g$ a' }7 s p0 G
.gpio = DA850_USER_LED0,& u1 e/ n: Q# t2 j
.name = "user_led0",! ~# l9 y; ^( C6 _; F
.default_trigger = "default-on",
4 \ I Q* `/ p2 b# E },
) k2 _/ W% z( D3 G M {+ @" u2 y8 `0 l+ v
.active_low = 0,( u6 U0 U, ~0 B* H& @
.gpio = DA850_USER_LED1,- [8 o$ x. K; Y' E" T* V
.name = "user_led1",8 L) Z' {, N1 o( Y2 L6 w
.default_trigger = "default-on",1 T+ {: W& L8 w; V0 `2 G
},
3 e% j3 d3 R- V' Q9 L. M {4 K9 C) r! e$ m* C% P
.active_low = 0,
; { V, S* ]" i) r# G1 u2 x0 t .gpio = DA850_USER_LED2,
3 G" P$ y x: a m9 D9 T3 ~ .name = "user_led2",
6 o* y& d6 Y, ^/ |* K; Z .default_trigger = "default-on",- H2 x! c2 o+ s1 A( ~
},) e0 l# b: F! A7 }( Y* _; `3 [; u
{8 ]3 a2 y! q8 I6 V& P+ g! ~
.active_low = 0,1 g. T- R) {% {( j
.gpio = DA850_USER_LED3,# ~3 ]3 v! @2 v. I7 l; B
.name = "user_led3",
8 o( m' z" m, ~0 H$ ~" x+ W+ Z- U7 h) [ .default_trigger = "default-on",
: t5 ^4 a- @! q0 `& O; `- J2 B$ k% S },
: h3 `0 `6 m p5 p# o: ^2 k};
8 ]1 s' l: v1 ]' @* G9 X: ?
( j, a+ k# b4 Z. M7 i& jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; s5 {9 Z$ J* ~7 s* C+ z .leds = da850_evm_tl_leds,
; L/ d6 s( z; C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 ?; m6 b% D. ^5 w# @# L};
% p! b3 f# n3 z/ {4 D' y
" G. `% j2 d7 Cstatic void led_dev_release(struct device *dev)+ z+ L3 B- I; I$ ^: Q& [
{ Z. c7 c( P- }1 S- O, ~! v/ d/ M
};5 U& B5 {/ n K* }* y% W
! a* b8 Y" \1 R3 o! {7 ]2 ystatic struct platform_device da850_evm_tl_leds_device = {
O- Y$ ^* X& _) P: R" W .name = "leds-gpio",# ?3 k( j0 N0 p& P: {4 P
.id = 1,+ _1 X- V% i; }
.dev = {
" p$ V4 H6 p) x% t .platform_data = &da850_evm_tl_leds_pdata,
- O# r5 E, n0 @7 e, O* n .release = led_dev_release,
6 q3 {, M: r9 b5 R9 Y8 G8 @* e1 q i }
* S" ?) {3 @) ~- }: ]0 V};/ v% o! C5 u; i
% n' G7 `. |, m: O8 K
static int __init led_platform_init(void)
/ v' y4 {. P% ?$ a" T7 Y3 C4 O{
9 p7 \0 k! T' w: ` int ret;0 z3 L& e8 e& W. y3 k, H
#if 0
0 J, P* ^! B8 F& V3 D; T# ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 d! |# e0 {. `5 E if (ret)
6 U: ?1 m# T( V; O pr_warning("da850_evm_tl_leds_init : User LED mux failed :": i& G ?4 T( m. h
"%d\n", ret);
8 m1 b3 N4 [$ l#endif
: [* c( n% n) M% P, N) N ret = platform_device_register(&da850_evm_tl_leds_device);
, A# H# @% o0 g! z3 r6 D& S if (ret). s1 S Z2 q. \
pr_warning("Could not register som GPIO expander LEDS");. S' L& B; G; W7 m \3 ^
else1 D% d4 i* H( T. H3 z
printk(KERN_INFO "LED register sucessful!\n");' R+ m+ E# C7 y* E* h
& F7 E2 D0 P' A2 L( f
return ret;# U# q& m5 `; \- E' b
}
; n5 p/ q; \; l" Z5 s" b; G: f; ?" j6 w) k3 K$ O; @& O
static void __exit led_platform_exit(void)
: U S& e, o1 k5 d# f; _$ j{
% w, F& p4 n/ D' I1 t- u platform_device_unregister(&da850_evm_tl_leds_device);
: c F! i- w- x3 c p# ^
1 E8 y# B4 u4 T& p printk(KERN_INFO "LED unregister!\n");
5 `% n+ ?! [5 A7 B}
7 y& [) j7 t1 M/ X1 K$ X2 n3 h% r1 A+ t9 c7 P9 `* y8 u1 _3 r M9 v
module_init(led_platform_init);
; p9 F0 x6 T# Q' Y, c/ ]2 Pmodule_exit(led_platform_exit);3 {7 V* e/ t4 a8 Q3 g4 ] n
' E7 K' T0 A8 Y# U2 ?
MODULE_DESCRIPTION("Led platform driver");3 w6 W8 z- w3 H9 B# A. J" Z
MODULE_AUTHOR("Tronlong");
8 a# M0 m F5 ]! |MODULE_LICENSE("GPL");
/ \4 e) w9 h0 x5 V8 u; p5 L3 M3 C2 `' z3 T: F0 X* d
|
|