|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# h/ ^( L. d( t- B3 K#include <linux/init.h>
: r9 U( u# u9 ]. f. h. O7 B, d#include <linux/module.h>5 T9 b/ V4 m7 P+ R7 @) z" G; [
#include <linux/kernel.h>1 e G; K2 s1 p9 T9 y" X/ T" l
#include <linux/types.h>
: y$ L8 ?9 Y5 Z#include <linux/gpio.h>
" H# {% H# y/ v3 a7 A#include <linux/leds.h>
" T- U' U1 M! T: v#include <linux/platform_device.h>
9 o. T5 M/ F& C" { C) j- F; }+ `& ~
#include <asm/mach-types.h>
1 l) W* y) J. h ?7 P* I( f" L#include <asm/mach/arch.h>+ k. ]' U7 @: L
#include <mach/da8xx.h>% d' m# l, G( i+ {. c9 o; K
#include <mach/mux.h>
8 _% p1 V. Z' V, C; M- Z4 I! W1 W
# w& K( R: O& v% Q& ^$ ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( d6 [/ T5 c9 U0 x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 j( H6 p" p- U6 D- }* A1 o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ ~: q' x( \1 }4 U1 B, t; H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 N# Z b3 }. g
# _3 t6 f. i, M$ Y" _/* assign the tl som board LED-GPIOs*/
) R& [$ O3 X2 {1 k8 Z. A+ _static const short da850_evm_tl_user_led_pins[] = {
( F# A( U5 B( F! ~' x2 A4 A /* These pins are definition at <mach/mux.h> file */
1 p: r- Q' x, {& t# k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 _: J9 M8 ?4 L1 _4 _
-1
2 _5 ]5 H* [3 S. \8 o) B};2 h7 M! X0 \ ]3 U, e
4 |* c& P1 I/ U5 [9 u! E* e9 a$ ^
static struct gpio_led da850_evm_tl_leds[] = {$ d2 }1 ?/ N( ]( w6 c( J+ K2 |0 m
{
# p d/ l" t' P5 c .active_low = 0,
5 ?/ Y) M" K3 k: L [$ j .gpio = DA850_USER_LED0, G4 U7 T& _4 {7 H9 |1 a+ I6 k
.name = "user_led0",
4 p. M( _; I7 `" v& a" y .default_trigger = "default-on",
5 K; m; X* a2 |" Q9 j6 @; t. f },
9 I. C, W+ s" {9 d3 M' X {) |3 |7 D: o! \/ ]
.active_low = 0,
4 n* v, E( B* F1 X; P; t q1 |) H9 m4 n .gpio = DA850_USER_LED1,$ z4 p) ^" E5 W' a( U
.name = "user_led1",- b/ \" s1 ?+ b4 }4 d
.default_trigger = "default-on",
7 h$ K& b/ t$ j$ B },2 P$ e. u; f( Y* D: ^
{
# u* O9 [5 c, A' F T/ X9 | N6 t .active_low = 0,
- a# Q+ N2 {; T0 n; P2 [- I9 g .gpio = DA850_USER_LED2,
5 G9 x' |# ?& }2 ~6 Y/ r .name = "user_led2",
0 Q2 ?" B( p' G5 a( @" n4 r .default_trigger = "default-on",
5 V& f7 i7 p) O1 i. b- p$ `+ B" ~- B },
; ^/ b6 A, k+ N9 ?! S$ Q5 _ {
* J: l2 \( c1 B9 W; G- c5 v .active_low = 0,# h7 D/ d! m$ _4 x! ?7 A$ J% x
.gpio = DA850_USER_LED3,: E( X8 g/ I \7 }. w% u
.name = "user_led3",
& ?9 d3 B) k) h .default_trigger = "default-on",
* t" t2 g& a% z. s( u* E, m3 m' T },$ _9 c) X X1 a
};
( f( g+ q/ _1 j" n
) t! n+ v- c& O* tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" ?: B% ^/ {5 t1 ?4 |/ Q
.leds = da850_evm_tl_leds,# x; b {; S, t( e" b) W8 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* @# e q9 h; a0 }3 g/ c* L, [
};
: e2 K2 G% I; F* d4 @. `& v
( {5 ^5 O4 `- a, ostatic void led_dev_release(struct device *dev)
% Y; R7 G: @, y* n, V2 Z$ H{
& I+ K# \: E9 d6 }$ S};
8 y& s1 C l! O5 `7 ^6 g8 w7 [- O9 X% d2 e& F
static struct platform_device da850_evm_tl_leds_device = {; {1 h6 s4 @( \( t& O% I$ Q
.name = "leds-gpio",4 I1 j9 q: Q/ _& z% N- M7 C" F' f7 s
.id = 1,
, ^, p( \/ r& W! Y2 f6 ^5 @- t1 m .dev = {* `: @ \6 A1 p; G' z. ?2 W( H
.platform_data = &da850_evm_tl_leds_pdata," L( h% _5 J, i- z0 j: L, ]$ @
.release = led_dev_release,
7 h; B/ p1 F0 p( [! k( W }8 l3 Z [ h# }9 y5 ]4 ?
};3 k. Z' r7 P# }; O" ^2 I0 F+ J
; E; H. w0 [ G" O5 |static int __init led_platform_init(void)
& w9 \. K* E" O( J8 g0 F U{
% w0 J+ @, B/ Q2 f int ret;
4 Y) p* V4 h) J2 ]#if 0
# I: c- t' e1 p& ?2 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. u5 A" m0 D' K1 ?4 X2 N, R! B
if (ret)
, q: h( U+ P# _, k! `. K pr_warning("da850_evm_tl_leds_init : User LED mux failed :": Q6 R! V+ o! W: n
"%d\n", ret);
4 a2 u3 r6 V; h" D8 n: n) r#endif* \' i7 X# k7 I4 K3 W; B5 a( Z1 S
ret = platform_device_register(&da850_evm_tl_leds_device);! a9 N R! u! S! z1 Z
if (ret)
( p( {3 n- i; k$ m* ~; ?7 X& E pr_warning("Could not register som GPIO expander LEDS");
+ f ~# k0 r( A6 d$ [ else$ S4 @" \' |" W i! S! ?
printk(KERN_INFO "LED register sucessful!\n");
b8 I, q* S/ y. T
1 m6 a/ `0 ?& {. B/ M1 v2 H return ret; ^; h2 u; F( f$ a+ j
}7 d* E k% H3 y7 S
2 t2 r6 i, Z0 N/ C- K- @/ |static void __exit led_platform_exit(void)$ Z0 q0 ~1 o' ], b6 @( K. I o
{
/ A( E. [- I J4 X( N platform_device_unregister(&da850_evm_tl_leds_device); i5 O9 ? [: @5 E
# C* p, X, [9 b2 A printk(KERN_INFO "LED unregister!\n");, q% ~3 i* W) k7 Y5 u
}
9 {8 H+ a: e9 u# I' [+ `1 S4 d
! W0 e1 U3 D& @; Xmodule_init(led_platform_init);
+ ~1 A! A" G/ J/ xmodule_exit(led_platform_exit);
/ Q7 M' J S7 w3 `. x( O% D% L+ ]9 S; J' H" t0 Z, H0 }4 _1 B
MODULE_DESCRIPTION("Led platform driver");
: B, W3 F8 H6 o/ v: Z9 _9 {9 {MODULE_AUTHOR("Tronlong");
5 c q. p' [# `4 o" G3 @MODULE_LICENSE("GPL");
: W: C }. M2 C; f3 t; s" Y2 @1 ~8 w8 u' L4 K- i# p
|
|