|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 O, L/ s5 \$ R! S* H
#include <linux/init.h>
0 _5 x& ^ v2 o; O8 V#include <linux/module.h>" s, \& _0 ~, d- x( B9 J& f$ d
#include <linux/kernel.h>
( E0 L! y- J4 N" m& T& R#include <linux/types.h>1 k0 @8 r* M$ n
#include <linux/gpio.h>& k+ O2 X, C" @1 I
#include <linux/leds.h>. o5 o/ c; R# i/ V4 ^6 g* A; x, o
#include <linux/platform_device.h>
" J Y, X7 J2 Y. D! t6 g T/ C. O, n$ R, L
#include <asm/mach-types.h>4 B$ Q" q! e1 ^1 c6 L1 e/ P' b
#include <asm/mach/arch.h>
) ~, P2 l$ d' {2 N e ~8 L$ ?#include <mach/da8xx.h>6 q: O; C5 s; Y H$ N1 \$ U
#include <mach/mux.h>
# D1 t7 O! v, [5 E! g) |6 z. Y, S: t& I) J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ f: Y% B* c9 m: l#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): Z3 R7 v; Y8 _ V, k3 H) T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* \) M6 ?" I$ D, |" F' ?4 U0 V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! s$ j& W! @: A, d5 Y' X% B; I' }$ F1 ^
/* assign the tl som board LED-GPIOs*/+ m% K) h) }, L2 n
static const short da850_evm_tl_user_led_pins[] = {5 L6 X& `& ]2 Z- X
/* These pins are definition at <mach/mux.h> file */
2 \4 _1 T6 y( } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ d3 N/ ] C& ~. l" @- @ -1) O, x, U* k$ a! |6 O
};: ~% P3 q: y% W' P7 p
9 K" G( Q h/ c9 t3 u1 a# Jstatic struct gpio_led da850_evm_tl_leds[] = {. @& z! z4 l' d8 Y4 S
{ j. L) q' N; g# a3 ^% _
.active_low = 0,
: v7 D0 o/ a& m; C+ l$ B .gpio = DA850_USER_LED0,
. u0 W6 ?1 Q( s2 u, w .name = "user_led0",
* Z! H1 t+ ~* ] `2 Q7 z$ a .default_trigger = "default-on",
2 H2 S: c9 i3 [& \: y },
& |+ F2 |, M+ w4 | {
# ^: B- j$ Q0 o: R& n .active_low = 0,
7 }$ P0 L, k: a6 m& ? .gpio = DA850_USER_LED1,- C* [' g/ \3 D+ Y4 Q. j
.name = "user_led1",
' L c: m7 t8 c$ J, x5 |8 X% X .default_trigger = "default-on",4 m/ s; H5 Q% L/ B
},. M! {: I( A$ R
{
6 D6 k7 z) i' a1 s" W4 m .active_low = 0,
. G! e5 E. `& i" I8 V .gpio = DA850_USER_LED2,
: p) \; Y9 b8 S, J2 c. T$ D1 g% M .name = "user_led2",! L# |" J0 J0 G! r
.default_trigger = "default-on",
, a6 X# y- r M' B3 ?/ G0 f' X },
: w4 p: u& Y8 C7 }7 g4 o {
, h2 X* z* {) l .active_low = 0,
4 V$ Q2 o0 ^2 a$ P O .gpio = DA850_USER_LED3,
2 Q9 K- l6 @9 [% ?+ r+ d k# ? .name = "user_led3",
' _" _0 l. B5 j" }2 K9 s. F5 u .default_trigger = "default-on",
5 j3 Y# I2 a6 s: D1 T( B6 M/ E },; e7 \0 |, R: q- {& f0 E/ v
};
/ B; x9 q* ]7 c0 _8 Z# r P0 C+ H
8 d1 J/ O0 u) k8 D5 s8 M/ Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 y* C9 H M( L
.leds = da850_evm_tl_leds,
5 e+ Q% P" y+ H a" x# x6 I- [- z- u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% h9 r4 h; B9 c1 L};5 B0 F+ C+ H; F+ ~5 J4 g
5 r% d$ l0 N+ x3 bstatic void led_dev_release(struct device *dev)% H8 l( T: \, u- ]) Q0 n
{4 ~) u1 e5 A4 _5 d( o |
};
% ?# m* ^* m; ~7 f# Y4 ^" l4 Y* }6 v8 w' F
static struct platform_device da850_evm_tl_leds_device = {/ q7 ]- N6 f- _8 T; t- l
.name = "leds-gpio",6 L+ n/ ~- J" k- s5 h
.id = 1,' I5 J* r- A ]6 g5 @
.dev = {
: x) K R" U; ~: V {* s5 n .platform_data = &da850_evm_tl_leds_pdata,
- d F, o5 b3 K .release = led_dev_release,) A' J8 r( G' ^% T0 d
}
( r4 ?) x/ ~* W: W i};
" [5 F* w- [/ h" O$ M/ i( h5 p/ j6 c% i0 k5 Z& j" O
static int __init led_platform_init(void)* ?0 F. o0 V& L" C' ?7 E& h; y/ |
{. z5 A- s2 Q$ O! D+ u7 D6 w6 s
int ret; ?/ w& T: H! @
#if 0
9 {( ]) w( t/ M! t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 P! C' c" f( D8 N
if (ret)
. a1 ~, \# c& R% V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 w6 D$ S1 R0 Q$ C" i9 B6 F( \& |( _ "%d\n", ret);
8 h3 [. M' d! Z: J" ~, E#endif9 l) ]# l5 _; Q+ @, n+ h
ret = platform_device_register(&da850_evm_tl_leds_device);
/ [% B8 Q2 k5 j/ R+ t5 t) m+ f4 @ if (ret)
( _! a1 I8 a4 D" V) o pr_warning("Could not register som GPIO expander LEDS");% |1 {, _: |0 |3 @: I& a9 V% }
else
0 u9 o& o1 t% h0 D' H' [ printk(KERN_INFO "LED register sucessful!\n");
) l9 B+ v: N% o( t7 z- ]9 d: D' M, \" ~9 W1 X
return ret;% K" h( P* O+ ^* n
}! q5 u5 ?* L( u$ H+ M. N
A2 {3 r" ?6 r/ \. n
static void __exit led_platform_exit(void)
( ]; B/ e8 H' X* a7 L% I9 Q. q{
. \- s0 n% ~5 H# L: z platform_device_unregister(&da850_evm_tl_leds_device);
' e9 t7 }% m7 l9 P% w4 \' w) d% k$ J8 e. F* Z6 b
printk(KERN_INFO "LED unregister!\n");
9 S. o- s/ [7 V! W}* O0 b& L- y+ t4 c
/ Q H. Q2 Z! {
module_init(led_platform_init);
1 y. l, G- m! i1 H$ S4 l$ tmodule_exit(led_platform_exit);
& V+ L0 C6 q! f; g0 l" t6 ~
% H1 U. g$ M1 A/ ^' Z1 ?5 YMODULE_DESCRIPTION("Led platform driver");
" ^7 w6 G) N( M0 f1 H1 wMODULE_AUTHOR("Tronlong");
3 f0 D0 g7 l+ h5 w! _/ F- nMODULE_LICENSE("GPL");
8 G6 W5 Y4 R( S7 _5 E. V* \$ K0 T$ h
|
|