|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 P Z2 G% s. Y ^; c6 `
#include <linux/init.h>
# V% e& }% Z7 N p7 X5 b h. u#include <linux/module.h>
7 B3 R4 s& j' O# n2 Y#include <linux/kernel.h>7 M3 h/ S0 B0 X( `- f% _
#include <linux/types.h>
+ }6 W6 v$ g$ U' U3 l x- _#include <linux/gpio.h>! t0 h; L( V- g9 d
#include <linux/leds.h>
7 K# q! \$ j3 R#include <linux/platform_device.h>8 J5 g& d) i$ g2 ?
" g5 T' R+ l7 m c( n, ]#include <asm/mach-types.h>
- E' p& n9 [% b. \7 M2 K#include <asm/mach/arch.h>
/ N) a8 q) i8 p' u#include <mach/da8xx.h>
+ u; C. _" P' |) B) O6 i#include <mach/mux.h>. T* e* w2 | p0 I; ]- L( y+ u4 s
& f) u$ V! _! @# E Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). \7 ~( l( |1 |5 r% Y! M/ E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) j9 ^: K) j/ {+ Y. q; B% X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ l f7 |2 ^# C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 n$ y! k5 a: |8 r6 L/ z, i o6 M+ I
/* assign the tl som board LED-GPIOs*/
7 v/ V. a+ i1 ^3 D; C- Wstatic const short da850_evm_tl_user_led_pins[] = {0 g1 G. ?) R+ Y p. u
/* These pins are definition at <mach/mux.h> file */
/ ` _$ M$ B8 ]; ?" t/ B+ {5 \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: F6 H0 p ^7 h6 E
-15 {( q/ x4 r% J/ T
};
+ i8 w( `2 I) Q7 d+ E1 z
) G5 M3 n' _& o( K2 N+ M' Dstatic struct gpio_led da850_evm_tl_leds[] = {% h6 {& p# ]- y7 h# H
{
+ _2 n5 }9 d$ O' t8 o+ C& O .active_low = 0,* ~- ~/ F6 C) p" v" E3 B
.gpio = DA850_USER_LED0,. }) Z v' T7 k3 b& L4 K. u
.name = "user_led0",
* ], r: d/ ?. A" ^1 A .default_trigger = "default-on",
R, d1 l9 _2 V },& S S! f/ I% Y N. K
{' f- `3 u0 ^% x& o
.active_low = 0,
: T. g7 I6 C; n( R4 i! F .gpio = DA850_USER_LED1,
# ^/ i& h& a$ W6 H .name = "user_led1",/ A# A6 g3 ~) ?& t& U* e
.default_trigger = "default-on",
/ `% y; q* f" B8 U2 f# u },
# y) Q; b9 A4 q; ^. d {4 E8 P. S% K2 N
.active_low = 0,
6 A& z1 |) O2 C( {6 W; u .gpio = DA850_USER_LED2,9 |$ \0 ^5 c K/ h0 G% c
.name = "user_led2",
) P( i% @2 m' s) P/ {, @3 S! ?4 s. E .default_trigger = "default-on",8 C( e) p7 O9 }; v
}," b4 |- A3 ]# t# q9 y
{7 f8 v/ k9 [7 w1 B; p/ _
.active_low = 0,
6 P6 F& @$ _( T, _& [+ n .gpio = DA850_USER_LED3,
3 E* E" Z/ Z7 r1 D8 S4 h4 q .name = "user_led3",2 `: |0 f/ _" T) D- `5 y( v
.default_trigger = "default-on",
' b# i: ^& J5 o& U6 H# \ },3 H- t# c k( T8 I
};
: P( j! N& b7 g* V+ l) W& j6 y+ m, {( k3 r5 C" d1 H( c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ b `1 p: V; W3 F* z0 o/ K
.leds = da850_evm_tl_leds,- w0 U! D+ C7 ~7 y( O. y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" ~+ Z! E- B0 _2 X* `1 b};
: n0 y: R5 r$ R
7 c6 ~1 K" l/ R, Tstatic void led_dev_release(struct device *dev). h8 U; o( Q4 L$ k; T) r
{
5 L+ l6 q: O3 C6 b}; a- ~+ w9 c. k2 @& T! |
* y( O+ r" U$ S, bstatic struct platform_device da850_evm_tl_leds_device = {
/ r4 C! r& }4 e" g .name = "leds-gpio",
+ W) n* O9 G* K3 B+ J8 G" q2 k+ H2 z .id = 1,
9 i8 Y9 H8 ?5 r2 e* s .dev = {
4 I' G1 o, ~* u- h* s1 s8 m .platform_data = &da850_evm_tl_leds_pdata,# g8 ?5 r# Y) A* D" X5 w
.release = led_dev_release,
. h( l4 u6 W: r0 p$ s9 c7 a }5 W* n* C& Z' G: M& [1 l$ X% X) r
};% F# u1 m* N) }- x( w5 \
8 l' ~2 j$ I) j& k' B+ M( C8 J; Bstatic int __init led_platform_init(void)
* }7 P; Q* a4 e w{
0 p5 p' b" H1 M& H; l u+ ?2 v int ret;
! d% J G% S) }. i" f* U#if 0
) n8 z4 |0 S* W9 U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: l9 V& C: @3 N: u7 \ if (ret)
+ M# W1 x# _$ I5 r5 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( I: I$ N, b6 I1 I' q+ R$ r& C
"%d\n", ret); r; b7 a- \2 W2 F3 ?, A5 ?0 B, Y
#endif% N }# w; r$ c$ X Z- y3 [3 @' h
ret = platform_device_register(&da850_evm_tl_leds_device);
% K _ @; q; K7 X1 v: M e+ o, F if (ret)7 Y- f9 p# Q {& T2 H
pr_warning("Could not register som GPIO expander LEDS");! _- v' u" x/ Q1 f, A! c( U4 i
else
! |2 O2 ^- K+ N- f% @ printk(KERN_INFO "LED register sucessful!\n");1 F9 C4 `* W- G! w p9 N2 B
* |% {% P: N7 \1 e$ v5 A" ]; W
return ret;
) Q+ I, Q) X0 y. J; g# b$ L( O}
5 r/ K: ~% A2 B( Z8 A( l2 ]2 g- m( d2 r' L! E
static void __exit led_platform_exit(void)! J7 \* s5 S5 U/ o0 `
{- m" Q2 ?& L% ?0 ?
platform_device_unregister(&da850_evm_tl_leds_device);" o6 n* H. t& i; B- e
. b, P: O O9 A# D+ X' ?; g
printk(KERN_INFO "LED unregister!\n");
* K# M* p7 E9 \}
" D [) M7 V) `- a& }/ ~$ j- ~+ T. T2 P5 W% F8 y' v# I+ C
module_init(led_platform_init);
4 h- d$ R: n g7 ?module_exit(led_platform_exit);" K2 Y3 O# ^2 g8 ^) x
; C, R$ L# S _MODULE_DESCRIPTION("Led platform driver");
v [5 J, E' W3 s8 l; Z/ P# PMODULE_AUTHOR("Tronlong");
: ~9 |# m( ]5 X' F5 T9 k* u( FMODULE_LICENSE("GPL");
6 K' G& ^* i3 F+ r( a) ?* M6 S f" I8 w1 Z, A# r) L
|
|