|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! l6 P3 v3 G+ W8 J5 U: E: k# `
#include <linux/init.h>0 g+ b! U3 X8 q7 n3 U
#include <linux/module.h>
9 D. A/ U+ p$ G# O$ f% @: ]#include <linux/kernel.h>
* o( }) w4 B$ S- e. I( E#include <linux/types.h>; E2 ^' G* ^/ G6 Q" `) J% U
#include <linux/gpio.h>
3 c5 C- P# m9 K1 o$ g( H9 R1 w#include <linux/leds.h>
4 c0 A$ B4 H0 k6 `% _! T( Z#include <linux/platform_device.h>
, V5 j: L4 n( |$ ^
( i J2 x$ l; U6 B+ i+ D#include <asm/mach-types.h>
2 h& S( c! i+ ?* X#include <asm/mach/arch.h>3 v8 [) R8 C& [0 @7 I4 V* C* \+ z
#include <mach/da8xx.h>! @- k# o6 l) N) [
#include <mach/mux.h>1 s( {& [1 d" _! T4 r* c, }: _
y& g& v% k6 E K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 j+ d: Q7 E( M! { D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) d$ ]3 A$ l8 `, K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' V) n& A- s& h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* d+ W J( x8 {% ]
( u1 [* ~. C. {5 @' r1 B/* assign the tl som board LED-GPIOs*/
# u$ Y# [4 w" D- W7 }static const short da850_evm_tl_user_led_pins[] = {
0 o3 B9 D& I; _$ U3 {# Z /* These pins are definition at <mach/mux.h> file */+ i' [6 S4 [4 F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 [& r. @! m7 m
-1
* y' ]3 }0 K3 t z) B};* p- l% t3 \$ I0 w- _
2 u! K/ B- c, ] J0 o2 q
static struct gpio_led da850_evm_tl_leds[] = {
% }8 P3 X y( ?5 D! _- k {$ M$ Y0 b3 D. R% [) X
.active_low = 0,
' {- g1 E. Y* Y" m .gpio = DA850_USER_LED0,9 u8 \% [' \( [* S* U& _
.name = "user_led0",: o' Y+ Q1 H* S# Q% u
.default_trigger = "default-on",
2 J; W5 _% @3 R$ W' C: U9 G },
2 R: x( E9 z5 U% A( V- } {5 s& { D, f' A) ~- Q
.active_low = 0,- d6 K* |' z- C8 Y2 w- Q
.gpio = DA850_USER_LED1,: c7 U. r6 {4 `: u* R* A* P% B
.name = "user_led1",, T @5 X' G$ N/ s3 x" J/ N
.default_trigger = "default-on",0 S3 @( k. Y' }; D3 Z y8 \; d
},
" b$ u+ R" V. V& c H. s+ H. m {
* I4 j4 k; I9 _ Q9 V .active_low = 0,
1 V& Q( S# [% U .gpio = DA850_USER_LED2,
% B3 W$ f, Z$ x0 {: g" r .name = "user_led2",
& ?7 {$ v# F, d' r7 x0 X7 ^) o .default_trigger = "default-on",
- j' f0 J& d2 b( C },
2 T: r4 J# y- X( |4 h {
) D& D7 [% i3 I) g# j9 L .active_low = 0,
) h ^- f R( v8 |* } .gpio = DA850_USER_LED3,7 l* a) |5 P# m* n9 m
.name = "user_led3",5 u: J& ]* w6 e7 e D
.default_trigger = "default-on",8 J( H+ w; C8 m; } R _; ]
}, |6 h: x: I( a; o* |4 Q: M
};$ {4 y9 O2 `4 F8 Q/ C
3 u# G' `" L4 Z4 mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 J1 Z. @ l1 i* s .leds = da850_evm_tl_leds,* X. u7 r& q0 p$ E9 J# b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; d9 F# D0 [! v( K9 @- H% \};
/ e: D8 O) x2 K% x% Z1 X, B# B' M" ^7 [
static void led_dev_release(struct device *dev)
6 F6 ^; r V; l( O- I0 t{
' i9 t8 t1 Z- ^. z; z3 V$ N* ?};% \& z" ^7 D. I( v" w) `+ P
( O! c ?3 `, t7 i9 O
static struct platform_device da850_evm_tl_leds_device = {
* G8 |2 q o ~ .name = "leds-gpio",
# }3 Y* \" [# F+ b; S6 r2 P .id = 1,1 n# } N! Z% O# m: \/ ~ n3 H: r
.dev = { T$ p ~+ o$ |5 z6 r7 |0 B1 w3 r
.platform_data = &da850_evm_tl_leds_pdata,
7 a) x1 e+ n1 r; L .release = led_dev_release,
) t0 A" a& e1 Z }3 J7 t2 H. T" e: ?, e7 ?
};3 h. f& Y+ U+ s" b$ ?) A4 l
! }9 i6 J5 Q: s' lstatic int __init led_platform_init(void)
% l' {1 Y O) Q{
# t0 z' ^0 i0 l c int ret;
0 X' D9 |+ v& v* b$ {#if 0
( X) ]6 b& }' M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" }3 i2 h( {# ~' R, c Z9 O T if (ret)6 R5 x: @3 S$ u* o/ [' Y6 Y% x9 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* @3 K; `" v' B$ _5 T "%d\n", ret);
/ {/ _" m! l& B! i+ M- h7 l#endif
H; u" P9 J* b+ M. C+ `$ G3 O ret = platform_device_register(&da850_evm_tl_leds_device);
3 Z" i9 E/ E) ~; @1 z: s, i/ }$ ` if (ret)
6 G) J, J; i" E. u/ Z8 Z pr_warning("Could not register som GPIO expander LEDS");
! d, q* |: |* T' H; A else- H6 w, [* w! A9 B7 `9 S
printk(KERN_INFO "LED register sucessful!\n");/ t* S2 S' {. L0 O% ]2 Q* B/ [/ Y% q3 u
3 E4 M& Z, b8 S! h% L8 H2 a
return ret;
* |5 {5 Y( y, w. X) v}
# k+ @# p( |& A6 Y& G# X8 f* o. h7 z% Z% {! Y! E
static void __exit led_platform_exit(void)
. G( ?% G6 q, O{$ T/ }, n; Z5 V8 @' k, E
platform_device_unregister(&da850_evm_tl_leds_device);
9 {, }" S$ D- Y. E: ~1 q
# P2 ~1 \4 h' P9 ^' P; v8 u printk(KERN_INFO "LED unregister!\n");" r9 P5 r: E# f+ y
}
& O0 A+ I2 f; k. g* R* h% R0 C* @3 x; x. A1 v/ ^
module_init(led_platform_init);3 c* I! L" K! ~& q3 y
module_exit(led_platform_exit);
/ y! Z |, s" ~- t; e# e" Q2 M: D. M* W5 m" ?+ L- @" H
MODULE_DESCRIPTION("Led platform driver");% R( f* r- I4 s7 X- r
MODULE_AUTHOR("Tronlong");
( K3 _8 L" f/ W+ ~7 n3 RMODULE_LICENSE("GPL");
" j+ x) K [% G6 C B
9 c U+ z2 O# q |
|