|
求大神给下面的程序做注解,请稍详细些,谢谢。2 [! I# t- z _( [
#include <linux/init.h>
( Q+ T i+ n3 r8 \ G#include <linux/module.h>
& {0 z# n1 s _& m8 m#include <linux/kernel.h>( s9 `, e4 o8 [9 o) w
#include <linux/types.h>
7 l4 x: W- T6 Q( i3 @* M#include <linux/gpio.h>
: O1 D( i6 u* g#include <linux/leds.h>
' U3 r, b( V0 @: A1 z#include <linux/platform_device.h>
3 t: I$ E! E' D) B# V1 s: n3 ~
7 D9 K% w$ R- {* U1 {" ~$ z- \" }# h#include <asm/mach-types.h>3 X; L3 l4 c5 u9 O
#include <asm/mach/arch.h>
9 N# C* F/ T6 @ }. x1 I% n#include <mach/da8xx.h>
4 u5 E! _, y5 @% k. H' o7 I#include <mach/mux.h>. G- v `% ^5 g) T. k; X
+ g' F' A+ I* i k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ i _9 i* I1 t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ u( e# k! r/ Q- v' u+ t4 m7 d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) p# ~6 t: q; T( j% D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' E7 M; ?! B& I4 @
/ X# u5 B9 x+ D ]9 O S$ }& e2 w/* assign the tl som board LED-GPIOs*/
% v d2 c' S0 y4 \- k! k0 D' hstatic const short da850_evm_tl_user_led_pins[] = {! M# c; [7 s# O4 j$ {
/* These pins are definition at <mach/mux.h> file */9 M2 W' O( K+ Y* G* m% ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," k, S. [* f7 w, _( q6 O j
-1
2 ?2 ?1 S; R6 U7 L9 j% f& J};
% |, @8 Y1 A- N& {% d) i0 U1 ~; \; I/ r5 ^4 f1 a. M2 r5 r9 o# b
static struct gpio_led da850_evm_tl_leds[] = {
& Z' x, w) U+ R7 L' n {
* {% G& [- s6 _; g4 I, a) b8 b) s .active_low = 0,/ e6 K3 L; O! P8 o- S
.gpio = DA850_USER_LED0,
! i6 I- Z# b2 i3 r w; R" A5 F8 G/ X .name = "user_led0",) i. e. r1 h& }% ?2 i
.default_trigger = "default-on",' J$ ]! A4 |/ F0 K- s" Y9 Y
},7 w/ m6 F3 w% X. Z1 ]% ]3 n" Y
{
# c1 u3 P6 r6 F .active_low = 0,
* i/ R4 e4 m) c4 x" {% c .gpio = DA850_USER_LED1,' Q: _% ~% T! s/ ]5 S3 R
.name = "user_led1",
' u+ C& o, n! v9 K/ l4 g" R .default_trigger = "default-on",3 z; I, U# P# @' o
},
* i/ w+ L+ h$ _% A& X+ } k! } {" O3 ]# n# t0 D' D/ J- A. X, Y8 g
.active_low = 0,& h/ Y" O( l! M
.gpio = DA850_USER_LED2,
4 p7 f; B! O$ H) D .name = "user_led2",
1 b! c8 f; W* D' G3 ^2 i* q1 g .default_trigger = "default-on",& B! |: g2 H: B2 \( @9 f. o# S1 t
},
8 ]9 Z7 W8 G1 g9 v* C! ` {5 n4 O$ X3 S) J* L0 E
.active_low = 0,( l: H8 k1 \8 a* H
.gpio = DA850_USER_LED3,$ z3 u$ I* ^( `! m
.name = "user_led3",- I `( O. v* j E8 \$ I& _
.default_trigger = "default-on",) ?7 n S/ n5 k- u6 [
},$ _( P# A. n+ c6 ~, |* Q8 N$ K# W/ a. D
};( h6 r$ o/ d1 C. @- |( h$ D
( `! k$ p6 X8 k+ Q# Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ w1 r! Z K+ P
.leds = da850_evm_tl_leds,$ g l& G* [. [$ r1 @% m' B9 I7 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" ~$ D4 B( h6 i1 P* u* }$ ~. v( g) J};
# ~& F9 m% O' q+ g0 W+ z
. I% g; Y9 o: x5 x2 estatic void led_dev_release(struct device *dev)
; W3 G# \7 ?9 I- ^' i3 d{2 Z' M1 t( G d3 y4 B2 A/ \
};
( F( @8 ^+ S- [5 V
2 w& U: u6 S4 T3 E! C* z' Sstatic struct platform_device da850_evm_tl_leds_device = {
: n3 d3 K* X3 {2 x, _9 h& z! S .name = "leds-gpio",
) d+ x- z! x" e, ~( B* j .id = 1,
, S1 M* q( [2 Q& B0 V- x: L .dev = {
$ q& G9 b+ K. |3 ]$ Y. g: U .platform_data = &da850_evm_tl_leds_pdata,
5 B, e! u! e& J5 g# d' ?" q5 ~! i .release = led_dev_release,: g) I% D5 m4 a/ Z2 `
}; F3 l: X& M. R
};
& d* E5 E3 O0 |4 J' ]" j
^, P) p" v. ? jstatic int __init led_platform_init(void)( d2 C, N' L# a" h' R/ j# R
{
! c2 a! Z- U; h int ret;
8 f/ l8 D% ~% G: v6 [#if 0
& V7 {) E3 I. l$ K* d+ } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 j4 I3 ]$ F5 g- n G( n if (ret)
, d: B/ d) s, l- s5 X: W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 `) A( [! t5 ~5 P; S
"%d\n", ret);0 B. E- K; `6 P8 Q, e* ], u
#endif; F) ~$ u! a6 w
ret = platform_device_register(&da850_evm_tl_leds_device);
7 g7 h& |3 m, F4 i+ [( f( M if (ret)# |/ M9 [& R5 }7 G% \4 ]1 X
pr_warning("Could not register som GPIO expander LEDS");
9 ~/ c4 |& R* t, f" ?" | y else% t2 B3 f( f9 K
printk(KERN_INFO "LED register sucessful!\n");' c; m+ j I3 f& ~0 X
9 V6 X W8 a7 ~0 k; i5 v' _
return ret;
& R* {- s/ Q; Y( K7 x}2 t' T+ B/ r; l. S. v6 j4 o) w
# u8 J+ ]/ L) m+ ostatic void __exit led_platform_exit(void)
& C* P* `) r- P- G" N% U" o+ h{1 q) O# m0 W, ?) _1 L2 |$ E
platform_device_unregister(&da850_evm_tl_leds_device);
5 j" @3 s# K6 I6 Z0 o8 p- ~+ k B
printk(KERN_INFO "LED unregister!\n");
( [: Y) |' }1 V& e# e% A v3 n6 Z3 Y& B}; X% {) a, {9 H9 O8 k
c! c) Y( j5 X7 h6 W5 p% o
module_init(led_platform_init);
* ]* i' z) j$ o" x% jmodule_exit(led_platform_exit);$ @# L$ w6 V1 ~& i7 \ z( m& p
; e8 n! y$ O7 c
MODULE_DESCRIPTION("Led platform driver");+ Y% h# W. b0 I
MODULE_AUTHOR("Tronlong");
) Y! N. m$ H6 I9 X/ QMODULE_LICENSE("GPL");
- | S) D1 N' g2 Z3 ?
0 ~: I3 S i; [ |
|