|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 V! G3 X, J7 c! _# _) l
#include <linux/init.h>2 \( Z2 U/ m. R1 r; k. ~
#include <linux/module.h>6 }( F/ W7 N/ v- _9 n/ g3 x; s
#include <linux/kernel.h>
7 `; P( M; G6 r3 |#include <linux/types.h>! D+ }* }. u9 y p! ]$ _
#include <linux/gpio.h>
6 z) ]4 m7 u7 o2 |" X0 {#include <linux/leds.h>) J( q' y+ W! k- D- p4 m" b8 `
#include <linux/platform_device.h>3 p% e0 z, V/ U ]+ c1 \
# ]! O# Z* z4 V; I0 T. x#include <asm/mach-types.h>
% ? u" u* J3 p- F9 X9 {#include <asm/mach/arch.h>/ B4 G, t0 W0 z2 p* s; v$ A, R3 M
#include <mach/da8xx.h>/ F. `# w- H$ o/ d( m, v E. b. ^
#include <mach/mux.h>! s' L' u2 Z" |* p' J/ y
/ w, Y/ m! C5 F( k2 m5 ^ N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ W% A: |- q7 }! f% I6 P/ J, |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ f* _: T: G- G. g3 } \" D: M( ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# v/ }' I8 M+ h- W+ s! S" h7 }( W' d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ ]; L' ]) h2 ^
& h1 U: }# X# P# m: @, u8 A/* assign the tl som board LED-GPIOs*/
& ~* g6 Q; z& g2 E4 z" k9 mstatic const short da850_evm_tl_user_led_pins[] = {
: X# V: g" ]) o8 L$ Y( U, D /* These pins are definition at <mach/mux.h> file */( F. A7 [! W. H3 B( b5 I# ^5 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 _& ?/ D9 @5 W% q( \; [8 @+ Q -1
0 v3 }* S" h/ l4 n5 Q6 q};
+ O+ J9 M6 U' h
; z' T, U- ^ j% w: {static struct gpio_led da850_evm_tl_leds[] = {
$ B( I) |' |" `& Z8 q! f) B; X {
* p' _6 P( J( U .active_low = 0,
4 t) ]: Z u4 c. n6 h; l: F# v .gpio = DA850_USER_LED0,7 q; u0 I: P4 V9 X0 M
.name = "user_led0",# L% m. ^3 v1 I2 E# j% f
.default_trigger = "default-on",
7 r! p6 g( s, a% S# O& V: P },- U g7 ~9 Z+ J0 }0 `" n/ N O
{
5 g8 X# F# u$ n Y- k .active_low = 0,/ p! E/ R Y. a' f A
.gpio = DA850_USER_LED1,
% {" q4 I6 c9 K/ d( L .name = "user_led1",5 D5 k7 V5 o j6 V0 k
.default_trigger = "default-on",$ K( @1 N$ u, M; t: e0 g0 M
},
' S' [" z3 _# Y# Z6 m" L5 R {
; S- y& i: {. V .active_low = 0,# m. V6 _$ ]3 o& t
.gpio = DA850_USER_LED2,. ~* ?0 U8 b6 c- C$ N
.name = "user_led2",2 E) D, N- L7 _
.default_trigger = "default-on",
1 w9 A8 X+ @; M6 z) |' T$ o4 T8 D },( ?2 e# x: d+ U1 Y4 V$ L; r
{
3 F# d/ H: _2 K .active_low = 0,
$ D3 Z; z5 E2 a .gpio = DA850_USER_LED3,
8 r6 h7 E% a" A. Z .name = "user_led3",
9 s- P/ M. W# s5 d0 v$ z* S .default_trigger = "default-on",1 A) P' W! Z3 i
},
. w4 `6 g+ G5 m0 J}; J1 S& k. t" q5 D& U
, U0 j5 _/ n6 [, B! l [9 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 d. d8 q( \' P% m' v2 f+ I
.leds = da850_evm_tl_leds,
! j0 b' A/ C3 @6 Y0 [& B7 z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 C' m0 ^) H3 Z) O$ X2 H" U};' o" O2 J8 z& U6 ]
6 s J: ?% F5 T4 i5 \, Hstatic void led_dev_release(struct device *dev)- t4 [3 z6 C3 v/ `! v( O# l
{
. B; K% j' K4 k, w, \# C};
4 \7 D2 h O6 M3 T. s( h6 e" h
static struct platform_device da850_evm_tl_leds_device = {( a) x5 s: v! z* \# ` B
.name = "leds-gpio",
+ o( X) w+ k' F7 j4 ` .id = 1,
9 F# S% q- F6 g' D- s .dev = {
3 v7 j# Z- \$ ~2 E) ^3 y1 p; Z6 X: J .platform_data = &da850_evm_tl_leds_pdata,+ ~6 Z, h0 n4 n( r, _
.release = led_dev_release,, k2 n7 y9 Y# a
}* g# r7 k ] G+ J+ P' G
};
! ?0 a. B0 k4 o. T6 Y
3 V# j$ [! O9 [! W' x2 |static int __init led_platform_init(void)
. E0 o1 C& d# N{
$ d3 { _7 L% g/ o9 g int ret;
* y _$ T6 }/ Y#if 0
: j, P3 t5 f( Z7 j, M: D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 U+ N. f* e) U# g8 e if (ret)
6 n6 j0 }' m6 m# ~5 _2 k, d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 S% v3 U! z2 Y) Y: r "%d\n", ret);# w; R# S9 Z2 z" s4 ` N# F
#endif( g/ e$ f" X3 z1 v0 C2 {/ ~
ret = platform_device_register(&da850_evm_tl_leds_device);
. @& T5 h( S4 k& g- t if (ret)+ `/ g( G0 ^+ j3 h4 q# U
pr_warning("Could not register som GPIO expander LEDS");. \# u. C% J0 Z) ]0 y8 o& t: {( p2 N9 U
else
- \: Y: f' j9 Q4 b1 v) g printk(KERN_INFO "LED register sucessful!\n");) M/ T% V9 L2 M0 @
7 Q* Z& o& W# d# b& M E" w return ret;* ?# D6 q+ @! D/ _1 k+ r! T
}/ }" U" J- E3 x& t
! o4 U, c1 }4 |2 s! o
static void __exit led_platform_exit(void)
8 y/ V" X7 Y7 k- M$ N3 s{
/ Q2 f8 J1 w8 T platform_device_unregister(&da850_evm_tl_leds_device);3 j# _ M: R9 q9 L
& v: i& w5 n! I U' v! {+ g5 O3 b$ d+ y( u
printk(KERN_INFO "LED unregister!\n");
. g( T% b9 |9 n, @. p4 t6 R}3 C3 ?1 H0 Y: v. ]# J
8 B& E9 |1 b/ Umodule_init(led_platform_init);
7 M& m9 w7 a0 G# \module_exit(led_platform_exit);: H* E% `5 a7 E: F! a& d
. b s' y' {8 L, y1 B
MODULE_DESCRIPTION("Led platform driver");2 ?* U+ l, Z( u4 C' Z
MODULE_AUTHOR("Tronlong");
5 `3 G% J$ V: _, y) Z4 d# G$ @) ]MODULE_LICENSE("GPL");8 t5 w* y7 k4 l3 L
7 V# K# d9 H7 i6 A( o. g
|
|