|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ c0 k0 I5 q. L# N" G0 V#include <linux/init.h>9 ?8 {9 _% L h( X' {
#include <linux/module.h>
, B' t1 R# v: M' y$ g( x I8 j#include <linux/kernel.h>* y; z/ H- h3 E+ b5 s$ [# X/ {
#include <linux/types.h>
! @* z5 U1 {. z' x1 @5 O) L, E! W. N#include <linux/gpio.h>' J0 m: k: [ [: V) h: g9 y
#include <linux/leds.h>
0 V4 a6 \8 _! T6 j# @+ ^ \- e8 Z, I#include <linux/platform_device.h>3 c$ s( D! b# c" ~1 Z! g: D
& A- s6 e( S: H5 U- n
#include <asm/mach-types.h>
( k4 v2 ~, k" ^#include <asm/mach/arch.h>0 S. _% H' @& T0 j% z
#include <mach/da8xx.h>
2 S( O5 P) k' h3 P, Z) H#include <mach/mux.h>" A! B' W" N9 b
( W. N( T4 w+ K/ Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! _) t% `$ y( M' s/ o& ?9 F" j. B! w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. V8 R1 {3 P1 V% |" [) j4 ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 T: k0 d! s5 j! E, u* j#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: R) i1 w9 T7 F
; J+ I5 ]) I& k; t( Z/* assign the tl som board LED-GPIOs*/
& M5 i/ g; z! F9 k, s# ~static const short da850_evm_tl_user_led_pins[] = {
8 w* E! B5 W* c* J6 C /* These pins are definition at <mach/mux.h> file */
5 k' p% ~$ b* i( } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 H& j" D1 D5 Z! ^9 g
-1* ] A0 V& W: k0 ?" N
};5 X- _5 R b4 n, x" V
) t. m0 I% j$ ]# O
static struct gpio_led da850_evm_tl_leds[] = {
* S# ^( A- ^$ }6 {# L3 g$ m- Y, W0 { {
- [) I8 ]# J2 Y9 U3 I6 ~ .active_low = 0,
0 N ?1 S N: Z .gpio = DA850_USER_LED0,
+ @: \. M! L$ z/ z9 j6 [ .name = "user_led0",: _8 R+ f4 \) P
.default_trigger = "default-on",
8 _3 M2 s: K+ R* s+ y" q: C },
* ?4 z" r4 [. K- M; i {; k/ \% o* y- B5 g' W
.active_low = 0,
. ^1 V) u: r/ o4 s* s0 P .gpio = DA850_USER_LED1,
" O, ?# A/ [% H3 w Q .name = "user_led1",# w, i# |" a6 J3 S
.default_trigger = "default-on",, I; W9 e b1 v, y
},) m- T- y. r; V1 s" {1 J
{
; @; | X: U A .active_low = 0," S% O" d. B: i0 }1 u
.gpio = DA850_USER_LED2,5 ^- B/ f/ L3 V; Z
.name = "user_led2",
- Y: ]1 c% R( z# e5 w6 E5 @8 r$ z .default_trigger = "default-on",: f% R5 ^: N( t+ B
},% }9 m( t. @1 A
{
$ K* t2 N/ E+ O% ^ .active_low = 0,
) f5 w1 k3 Q/ g8 X .gpio = DA850_USER_LED3,
6 B+ K! y9 L# T H3 }" H0 c2 y. S .name = "user_led3",- j6 T, q& K( t3 n" z8 p' ~5 y
.default_trigger = "default-on",7 ^) U. z6 f' q1 M
},! P* |, j# h0 w& K7 |2 `
};& }' E5 e9 f; B! @2 T6 r
3 Z Q* g& ]) k3 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { h6 X7 I. }+ ^$ [ j9 b! x
.leds = da850_evm_tl_leds,
' l& k( X* \5 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, x5 Y. H0 @7 @% E};8 n3 e" _# j7 l: q: {
& F. ^7 y4 `( |! G/ ~; V
static void led_dev_release(struct device *dev) R. d0 d' X0 a- d) a
{
. [: `, {, [6 V};8 _5 `! d" \- ~
( I% e. Y: b; n5 P1 D$ P5 m
static struct platform_device da850_evm_tl_leds_device = {4 i# k0 ?7 v. j
.name = "leds-gpio",' l- ], t2 v. F
.id = 1,0 z- V/ V7 z6 ^6 W3 ~$ `8 M# p
.dev = {
0 T4 v \% Y& Q( f: V' q, H .platform_data = &da850_evm_tl_leds_pdata,
4 \* e# S- f; U, H; ]) Q/ v .release = led_dev_release,5 X8 q' @9 b3 ~5 s6 E( M! W
}
, h& d! d) a. i- X( U5 L};
# m$ {4 _+ ]& m; c A9 f( y3 R
" a# V# g: ~; ]+ S; U0 U6 zstatic int __init led_platform_init(void)
9 \- Q- @$ ?# l1 M+ B# ?" ^, P{
8 R& Z: h% h+ Z int ret;! h# X: Y( u b% [7 F: P
#if 0+ [+ \( J3 M+ o% b% Z- [5 b/ }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" g% S0 p* I6 U" f if (ret)- J1 i8 W" I% P. N3 E9 w
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 e9 v! E# @8 j8 t5 Z1 x "%d\n", ret);+ i* |. F, D7 j2 q7 M# y8 B
#endif8 F) t6 Z5 C- P0 e2 [
ret = platform_device_register(&da850_evm_tl_leds_device);
0 [/ W, J1 a8 P+ @, H5 V5 u) l- j, v if (ret)* a, \& p! y8 d3 }
pr_warning("Could not register som GPIO expander LEDS");
4 [( k6 u& A9 V1 n- ^. P5 ] else
7 ?7 }. ]8 V; [0 a' Z% K# d printk(KERN_INFO "LED register sucessful!\n");
+ D7 S: t1 b# ? b: ^/ j2 L; ]
& J4 @& q$ I* e5 {5 ^2 H1 F1 l return ret;, ]% t8 R& T9 w& o2 N) w* y
}
1 j! y4 c& Q7 D [5 e1 s
6 k! R0 H+ I; L: {static void __exit led_platform_exit(void)
& H3 c$ }' ]$ u{( Z) o6 k. m# g& V( {7 K; w( Z$ P
platform_device_unregister(&da850_evm_tl_leds_device);
- s) a* l1 n6 f5 r. v' O4 o/ d0 B) f$ \+ v. D2 i, a1 Y
printk(KERN_INFO "LED unregister!\n");$ r' L$ i+ Z* f% ?
}
1 H) Q' @- { B8 [$ M# Q( l2 N$ Y+ d2 ]4 N
module_init(led_platform_init);) D2 [0 M; s+ Z
module_exit(led_platform_exit);
) F+ M4 I! R: }- T* P: X* [& Q: U1 x$ U- E* N+ E$ y8 {4 I
MODULE_DESCRIPTION("Led platform driver");9 o1 ~9 g" X. D
MODULE_AUTHOR("Tronlong");5 { ^4 s) Q6 s- k/ Q- N
MODULE_LICENSE("GPL");
% r$ h C: s$ m' O$ T: F' f( D# Y" Y# D6 D, l; |4 b
|
|