|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* {* Z' g. y9 p: [$ Q# s/ T
#include <linux/init.h>
+ h' {5 `- |( h( P! N( s8 F#include <linux/module.h>% M+ J. a. s9 W# c) Q6 T
#include <linux/kernel.h>
# L9 Q( l5 ~; ?7 ~" ~" j#include <linux/types.h>7 _3 u# W8 z- Q7 H
#include <linux/gpio.h>5 ^8 M' E2 A4 \/ W' Q& Q! x8 H
#include <linux/leds.h># I" Z3 K7 e; R' x7 Y! A4 I+ f+ y
#include <linux/platform_device.h>
4 p2 R$ J" ]1 h& x2 a$ W) Z1 O. E
1 V6 ^& E0 O+ G+ f' @#include <asm/mach-types.h>( c8 _# Y( t$ C6 Z7 _
#include <asm/mach/arch.h>
" S% |7 H) L3 O* A8 w#include <mach/da8xx.h>( C9 W- U' p8 }$ I: t8 H
#include <mach/mux.h>6 O5 G' U. d& G% Y" O
3 c- f; B9 c& u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ [1 n; W. E: ^& i! \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# B# ^2 w/ o' Z1 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 V3 M4 M& x) r( I5 h4 `/ b* g& T6 e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# g9 g! l) }/ v: Q5 J5 a# R
: s5 g# ]. P4 z# m3 Z8 A( _/* assign the tl som board LED-GPIOs*/" W$ \# K" y$ a+ Y" ~. T+ Q' T0 E
static const short da850_evm_tl_user_led_pins[] = {
/ x- m9 _0 c5 z% ]! C& w# _) N4 t /* These pins are definition at <mach/mux.h> file */( B a# b: P5 F7 V+ k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& |( l6 w$ H; z& ]2 @ -1
/ c! n9 E( g1 J" V/ u1 B};
4 m1 m3 F/ B4 a" U
9 O7 @4 M' W _static struct gpio_led da850_evm_tl_leds[] = {
2 F1 b0 P7 A$ P$ j- K! J3 J' g5 E, N {
D" @+ m# A" v/ z# F' V% H .active_low = 0,
( i0 e; s: `$ g7 g8 }- Z$ a .gpio = DA850_USER_LED0,
2 Z& x6 J, ]/ v8 B. n1 W. M .name = "user_led0",+ u6 @! N8 U' s7 b
.default_trigger = "default-on",( I( e. g, g( M
},- V" ]* m \9 {8 s2 X9 R% J6 W
{
9 T" l P1 A9 h$ C! a. f! l# O: ` .active_low = 0,
7 @( g1 B# T% {6 e* U& `0 i# k `; C0 S .gpio = DA850_USER_LED1,$ n) K7 ?- n! F2 e# i5 v
.name = "user_led1",# r; D) [: d% E# P4 o' e
.default_trigger = "default-on",6 {/ h0 A/ Q! v5 m
},
& ?% ]9 }9 O4 s, S {
* ~6 L4 S+ z; v+ n: g .active_low = 0,; r: B& y4 P$ [' x X; O2 f
.gpio = DA850_USER_LED2,( V3 G) H' P5 G
.name = "user_led2",
$ \+ L1 D, F6 s7 Z .default_trigger = "default-on",: R4 y" i3 |) J4 I; t
},
& Z& j; c5 T6 k" i0 r$ b* n {" z5 _% t" Q* z- X5 x5 T2 l
.active_low = 0,; Y& u* ~3 j# _9 a9 i; X
.gpio = DA850_USER_LED3,
$ N$ L. z9 @7 v .name = "user_led3",
# n2 |$ e, \( ?, y .default_trigger = "default-on",( D( z% d% \ p& P& O/ F
},
$ ~ @. f. z& u9 a- ^};
1 C5 B9 W G1 x s5 S5 [9 L2 f/ ^
2 \' }' M* s" s/ nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 ?6 j. @8 H6 c% V( v
.leds = da850_evm_tl_leds,* I$ c" b9 {( X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: l: A* g. c! L: N$ N7 |5 c
};
t. U( @8 C! B- Z7 P. t' s6 d I# I6 h% a
static void led_dev_release(struct device *dev)% {% k' t1 k F/ v3 _7 F1 L
{
+ E3 c5 W' O- w& R+ i; Y};
& x& c* e3 w, C' W
$ S% J% P+ C5 J0 z- G" a# ~static struct platform_device da850_evm_tl_leds_device = {' ]; u$ D0 [# ?8 J
.name = "leds-gpio",, V. L6 S$ l h9 C4 q
.id = 1,, _9 b* A) U) c R$ u/ @, o5 P5 x
.dev = {
I; \7 ^8 q4 r' J! D: v. s .platform_data = &da850_evm_tl_leds_pdata,
. b5 m7 B' H9 `1 O% f5 t) Y .release = led_dev_release,
: H6 j* e% F1 e }+ K% L- H. z; X1 l' q/ N
}; A g- }3 c4 O p: ~7 `
3 ]/ S6 N; h; A5 X
static int __init led_platform_init(void)2 H% q X% l* o) H. Z
{
" T0 f* T% L0 D% h1 q int ret;. Z+ m! A4 C4 r3 H# |# c
#if 0
) b" w7 T: m" E- j# t4 u7 x1 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" }! ~% V3 a+ k. g
if (ret)$ ]; e: J- _7 K+ B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; h; _7 p$ Q- O! x9 U5 r9 ? "%d\n", ret);
! o' X8 z- O$ [/ ^, A# S#endif
2 g6 B( x1 I" w ret = platform_device_register(&da850_evm_tl_leds_device);- s \2 i7 x0 N% o5 [" [4 u
if (ret)$ M) k4 F- e, N
pr_warning("Could not register som GPIO expander LEDS");7 ^" d" W n- ~+ j) W, Z3 @# m. l
else9 \7 `/ |6 R" C" \
printk(KERN_INFO "LED register sucessful!\n");
, e& @% F0 I. @0 x# q% f9 s1 ]) Q- j+ i4 m: ]6 m" v8 C: X
return ret;8 r% H/ R3 ~ R& G9 M) Y' @; i/ ]
}" c" [1 n4 a) r+ Z7 E; K- t
. ~! \( v$ B- T V, y2 V3 c
static void __exit led_platform_exit(void): j! e) @6 f: @" ]1 P; \
{
; w/ p0 I( _2 Y5 T* L2 K8 w8 ~ platform_device_unregister(&da850_evm_tl_leds_device);3 X' @. t, [. d5 e% _% P! U; K
" _9 v0 o: {8 E; E) f0 i! o printk(KERN_INFO "LED unregister!\n");
) [1 V8 H, m8 |/ L( k! b}
+ w( T: C* L) m$ k6 q5 _7 C7 j, x7 E* c( X1 L- ?
module_init(led_platform_init);
5 W5 r7 |* G1 h, ]* O* _* hmodule_exit(led_platform_exit);5 R# Q, B: Y, i2 ~4 m
$ R: n1 G2 b0 h' _3 FMODULE_DESCRIPTION("Led platform driver");4 w& l, ~$ q+ U3 I& }& h5 F
MODULE_AUTHOR("Tronlong");
" b1 N3 y$ o) jMODULE_LICENSE("GPL");
, K3 v* f P! G: Q
( g! e I# J! v0 G1 j |
|