|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 N9 ~1 O' ?* U" \
#include <linux/init.h>
0 K- c; Z6 c2 R9 Q( ?% w#include <linux/module.h>" w0 g" R6 [# \' A1 m
#include <linux/kernel.h>3 X8 W; T7 J9 m) t: P
#include <linux/types.h>6 O: o3 w; s% `1 l; z
#include <linux/gpio.h>
) K9 a6 T) P* J4 c#include <linux/leds.h>
; w. l! M5 E7 r7 ~#include <linux/platform_device.h>1 s9 s" W9 m$ [% o1 D! q; a6 M
7 [$ ~2 |- X) b+ @, v! K" P
#include <asm/mach-types.h>+ G, c+ H2 @. r7 N' b6 L9 Y* ?
#include <asm/mach/arch.h>% `/ P2 O$ G3 t
#include <mach/da8xx.h>- d8 e! I/ l/ p# M) X, T! D8 O
#include <mach/mux.h>- C3 x( ]/ ^: ?5 X8 w: |
( J1 h. l7 K6 P. \1 z: V2 ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ \# V3 ~7 ?5 @3 M$ q( D' e. J1 T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" g: L- y# P0 B3 R% ]+ g# I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 c9 m3 ]1 [$ \7 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# T" v6 a4 l: w; W% R3 _: x; W3 g: y! w
- Y( L" x3 K- a7 X4 Q/* assign the tl som board LED-GPIOs*/
; T$ M2 A) Z; U1 Lstatic const short da850_evm_tl_user_led_pins[] = {
0 Y; u8 y6 h/ m: q /* These pins are definition at <mach/mux.h> file */7 J* O2 u" Y- N* ~% d0 V \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ j+ |0 b3 G$ Y @6 L7 p) r9 A -17 r+ X( y$ L+ c4 T& W
};
4 O4 Z$ T! H, B3 Z" _' ]# U: x
3 x6 ^. N0 O& r8 y3 _- f% Fstatic struct gpio_led da850_evm_tl_leds[] = {# U2 s; C1 A& w
{
) t) X, x; O' n7 _) X5 i2 N .active_low = 0,! c" }# k& l1 g4 ?3 Z1 F
.gpio = DA850_USER_LED0,6 g2 C- [! k& l/ V `7 K& c
.name = "user_led0",
7 u# E1 H( g1 j. f .default_trigger = "default-on",$ q5 U6 b0 t8 [" I
},- T1 m$ u, A+ T( P6 b
{- z* H5 {/ F' w. E! K5 O/ K
.active_low = 0,
6 _$ h' @- x$ C .gpio = DA850_USER_LED1,4 F' o; o! { ?+ t
.name = "user_led1",
" \: _* _: E; E3 f, U3 y% G! U. w .default_trigger = "default-on",
0 b8 N! s: i- ~8 R/ P },# w4 i0 x" Q4 D! z
{) y' C* M4 p* t* [4 L" }: V
.active_low = 0,
! l3 c5 ^$ l1 Z .gpio = DA850_USER_LED2,* L* P @# q ^6 n" o
.name = "user_led2",
) ?8 `9 X, c3 C9 v .default_trigger = "default-on",' E' W7 O) T6 N9 L+ R( a' t/ U) T
},
# {" L% S9 F8 v/ \" i$ i* Y( K {$ _0 s! \! I" S/ p) k
.active_low = 0,
( f" x# i9 }4 \3 r- ]+ f9 v .gpio = DA850_USER_LED3,
) F. p4 T4 Z$ @3 V$ S& S6 m .name = "user_led3",7 o8 Q" l( {$ n: ?- O
.default_trigger = "default-on",5 \5 H" o4 o/ P a { z
},! |3 a$ _% B E* U% P# C9 t8 W
};
: @) d. ^* Q, h! o$ R; O8 d9 W& J" O) k* H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 Z# i* P( V5 w8 n2 f$ O* j .leds = da850_evm_tl_leds,
4 B6 E$ j. [) \* x' Z! Z# m' Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( _" b4 w+ z9 k0 ]; M( \
};
" `# ]9 _# d4 X# g1 w: a8 k: ~0 {1 L8 a$ c( @
static void led_dev_release(struct device *dev)+ Y6 n* K- E5 n( L4 }& v
{
- {, B% m6 I5 \3 Y/ [};
6 K8 d# T6 B$ V. p a- r3 _4 ^; t7 L" \' C
static struct platform_device da850_evm_tl_leds_device = {, L: E, v& ~& A7 P& E
.name = "leds-gpio"," n4 C) z5 i2 K6 U9 t1 ~
.id = 1," W8 C' g g2 z3 M: E. F. b6 f
.dev = { ^9 @# e- x2 g) A4 `
.platform_data = &da850_evm_tl_leds_pdata,
, {) I) S9 L! \& j8 o .release = led_dev_release,
. h# y9 l; j; e }0 T* U: `' Q3 ~- c' \0 z: t
};
9 J3 { S$ w6 u$ O" O; K5 G$ G
3 v: H. B( w6 Qstatic int __init led_platform_init(void)
4 B/ t/ n* d) u% {0 c{) B) @$ S6 F. y1 G8 ]! R
int ret;" v9 |) [& ~* H: y" {
#if 0" N% W8 ^7 V( [: S, g& o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, e/ c( p! @' y- Z+ k; ]
if (ret)/ I* ]" d3 [* z" S8 S( o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- x* d; \( Q5 y( w! r
"%d\n", ret);7 l; d$ X9 T" \- F) J
#endif- O# v7 }; y0 m" r4 ~
ret = platform_device_register(&da850_evm_tl_leds_device);$ k, S/ o" U. ^ w2 e5 l
if (ret)
8 i u' @0 q4 } pr_warning("Could not register som GPIO expander LEDS");! Y* v! A/ C1 a" d4 g( ^: ]
else
1 w5 o+ Q! W; V5 ^1 w) a printk(KERN_INFO "LED register sucessful!\n");' a; E7 q3 {' y( }
3 p& m8 @+ S! ] return ret;
+ J( a, X9 A! [5 P, e}( N0 l) j9 S; @* t0 h
( { ?5 ]( ~0 I( p! D& S+ e6 }
static void __exit led_platform_exit(void)
6 G3 d* _# h1 X! R' `{, m8 p6 L% U5 A
platform_device_unregister(&da850_evm_tl_leds_device);9 y$ G1 I3 R j% O6 h; ]$ }% F
F; b. G g2 L9 v: { printk(KERN_INFO "LED unregister!\n");
8 X: }. D* _/ J4 \/ z/ x}; N7 C! c; t& ?& k! K
. f3 h3 U4 i9 W. R
module_init(led_platform_init);/ s# M: |$ D% }
module_exit(led_platform_exit);2 r' E& o% D, L) q3 \
% k1 F# L: {5 {+ f: g2 g4 U7 G5 T& \; G
MODULE_DESCRIPTION("Led platform driver");
2 O' _6 l: L# E ^MODULE_AUTHOR("Tronlong");& X' H0 Y: ?; m. f% F) Q' u p& k
MODULE_LICENSE("GPL");( h& U5 s& H& U; H8 F
6 S* }0 `* N* K; e/ `- Z6 W |
|