|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% q# [( T0 [" D2 k) d T2 T: W
#include <linux/init.h>
9 p6 o! m. p/ X$ |#include <linux/module.h>- x# x1 M" j9 O+ z
#include <linux/kernel.h>
# K/ I8 ?$ f$ H& j! J0 `#include <linux/types.h>
" _) j: B8 c! A1 W#include <linux/gpio.h>
/ w2 u4 F* }! u, n1 S5 r ?: F#include <linux/leds.h>
& v$ j/ U2 h6 }2 |4 ^9 O#include <linux/platform_device.h>9 A/ ^$ g+ b1 r0 u+ ~& }2 T8 j
s4 g( p8 R4 T8 @. X( G% n; o8 K3 T#include <asm/mach-types.h>
7 j7 Z# g9 `: a* H* K# x: R6 j0 z#include <asm/mach/arch.h>
1 E) d$ }$ U* z& Z6 [7 q#include <mach/da8xx.h>3 U$ j# a& \' ^/ s
#include <mach/mux.h>
! I( y- Z: R" t" U/ E* Q# E" Y$ z4 }( J8 k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 E5 X* w7 a8 V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 A$ A! d- e; l# Z; e: \: c, ]2 H& D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" s8 h% H u& z* T/ \5 j o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 i& j) O$ J& u, o# d" `' s6 {0 r, G7 m. F5 F
/* assign the tl som board LED-GPIOs*/
2 [& \2 B# q" U3 Y6 j' f1 Pstatic const short da850_evm_tl_user_led_pins[] = {
9 }. Y& N: |' r /* These pins are definition at <mach/mux.h> file */2 u3 J2 R& J8 F: G. C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ n6 p3 H& c" s; S/ d
-1
$ F: X' \5 c) T5 h/ f" V};+ N: E" y& O+ F' J, R* c
, D M# ?; L& V- e8 b+ d( Q2 N! ~: Ustatic struct gpio_led da850_evm_tl_leds[] = {
8 `0 U1 z1 _( w4 Z {
! D4 q8 V8 ]3 n8 \ .active_low = 0,
# C ^$ U' O+ a$ A2 @$ l .gpio = DA850_USER_LED0,( ^; a- f1 E: N& }
.name = "user_led0",; J. b& }& [- X0 f4 Z$ s; v
.default_trigger = "default-on",1 ^6 R a' ?+ s% W5 _
},8 I) x8 P! w/ ^% u5 k
{6 d$ O2 @2 r6 X) f7 \% a9 R9 c
.active_low = 0,% \* I* i/ f7 z( c; |7 P
.gpio = DA850_USER_LED1,
" N2 s9 t3 I. B" b6 ~ .name = "user_led1",
4 A0 n- l2 x0 ]: x( l .default_trigger = "default-on",
3 g8 b+ f7 m* \6 c+ G/ i* m }, R6 D* g, B( n7 c
{
. p$ Y2 x, x6 E0 g .active_low = 0,
# {$ E0 E0 D! W \' u8 S7 H .gpio = DA850_USER_LED2,
$ Z1 S4 c+ }- O: D# f .name = "user_led2",
% m. w" k- {4 e( i. Q2 P9 p .default_trigger = "default-on",. o6 `3 j" G3 G X$ ^
},
C; r0 g1 f- G! b. |+ p# f {
( t0 r; }7 ~, O( u# `6 J3 T5 R .active_low = 0,
" G: S$ `" B9 A* F1 M .gpio = DA850_USER_LED3," f. K8 P* b8 I4 Q& y
.name = "user_led3",* b/ J9 _# V- y+ j
.default_trigger = "default-on",
3 _" |' I' Z% G },
. I7 b$ c4 j* n; f8 V7 F};
' G) q- q- _9 M& W4 F! n
- t2 v' s- E) n) k! W9 N" R6 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 I2 t( G" M1 a$ [. m% M2 }
.leds = da850_evm_tl_leds,3 Y3 s' M1 u# p& p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 G$ q& \8 l9 K7 @" E
};
! ^8 a' Q3 ]$ u* ? ]. Z" W( \' R- c1 C! h3 W, }
static void led_dev_release(struct device *dev)
* _: `7 R& c9 @9 E0 {( e% @{ i5 a2 h' U4 t, \5 ]/ s- ~8 T8 i
};' g& A0 j+ C- H u
" |) I* D6 r y* Q+ M6 R. istatic struct platform_device da850_evm_tl_leds_device = {; F/ w! \3 ?/ a! j
.name = "leds-gpio",
# U4 [) Z, ^4 A3 Z b9 l) ^ .id = 1,
6 d" h, Y- e8 k5 k% {0 H7 i/ | .dev = {: U* ` A# d/ }( V% S; {/ i
.platform_data = &da850_evm_tl_leds_pdata,
, j) i" y" e' ]6 H( i .release = led_dev_release,
U9 i' a" z3 b8 T3 ]8 p }
/ E+ n! e" N& S3 Q+ `};
8 [; r7 L7 l% L1 Q& M; v3 f' [
+ _& x0 V5 K8 ~0 p: U2 `* dstatic int __init led_platform_init(void)
. d& p+ w3 Z" ~1 B, h{" z! C$ l/ p; A& F8 g
int ret;
$ x8 A* [$ w! N' g7 B#if 0
: @( G: s/ _' f& @/ x) t' v: A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& A1 Q- [4 @4 h2 G7 `
if (ret)" Y0 I4 P9 E2 L Y$ D9 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 I1 p* E# I9 r8 x2 s
"%d\n", ret);8 F$ Q# m8 H0 F* P |
#endif
* h/ M' M4 [, M# X ret = platform_device_register(&da850_evm_tl_leds_device);
2 T5 P# E/ ]5 @. z* ^ if (ret)
! p% O+ m4 h+ W) p! Y pr_warning("Could not register som GPIO expander LEDS");, q- @7 U; z$ j$ D
else
/ ?# a( }4 @# q printk(KERN_INFO "LED register sucessful!\n");1 ~9 |% P) i* P# [
! b( r! ?7 R- m8 E1 |) t return ret;1 u7 W2 @$ Y0 N2 ?2 m' F
}1 z& l5 h6 J7 o" \3 C0 @5 c" Z
, [! T: ~% J! z% v' D
static void __exit led_platform_exit(void)
9 W9 ] S, @ X( o1 F# J{1 }8 Q: k& O* [, ~$ P- _
platform_device_unregister(&da850_evm_tl_leds_device);
! |4 \4 m- j0 G$ R$ N) V# r0 ^
( g: c& {8 F3 F1 S B/ r printk(KERN_INFO "LED unregister!\n");
2 `% W/ t. d0 c, g* r/ q/ S2 [}6 e* _2 k7 c+ ^, r' v2 |. I5 K
- w2 ?3 E! U8 G, I. {
module_init(led_platform_init); |8 J+ H6 c! L d- \# _
module_exit(led_platform_exit);
; D1 U1 M5 v. P& }1 q+ K1 u& [, u# F, z; v- P$ ]. M3 W8 u* F
MODULE_DESCRIPTION("Led platform driver");
- @7 T* z* I( YMODULE_AUTHOR("Tronlong");
1 [5 ]% S6 Q7 v& J( @# f$ dMODULE_LICENSE("GPL");
) K! i3 I* t4 [( g9 C: c$ M- [( K; ]/ a' {
|
|