|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, e) E( m# i; f; o
#include <linux/init.h>
5 p/ Z& p+ W' L/ ?- R. V# \#include <linux/module.h>
; l o. I9 n, ? r9 Q2 ]" ?* ?#include <linux/kernel.h>- p2 Q3 j# g: h0 t
#include <linux/types.h>& @+ V/ _+ ?, s3 m$ E5 _+ M' S0 o
#include <linux/gpio.h># U3 ]. z; j, U8 x1 Z( R% P
#include <linux/leds.h> a3 i6 h4 [+ }+ A( G
#include <linux/platform_device.h>
' @ ]6 K* u+ p, |9 `+ ]3 f
( V, z5 q, u* J0 ^#include <asm/mach-types.h> \/ g& Z/ _0 j8 K) U0 Z
#include <asm/mach/arch.h>
- T7 k) p, F0 x9 \, B) r8 H( e2 A#include <mach/da8xx.h>
& q W5 H1 E6 G& m1 }+ T#include <mach/mux.h>4 k9 V! J% t! j$ F0 D" V/ o
/ t: x& O9 C+ z9 B- H) e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: B4 E7 i8 Q% g* @2 v: m" B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 G4 ~1 t4 I" z, A9 {3 [8 W& r
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 l% k& I2 a! }. r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ i: y+ Z6 ~$ g3 m4 v, p: g$ \) _+ C: g) y, S" }
/* assign the tl som board LED-GPIOs*/- ]& b* R3 S9 A2 ~
static const short da850_evm_tl_user_led_pins[] = {% O9 R6 c0 R4 T$ t# @- z. `
/* These pins are definition at <mach/mux.h> file */
' S, K, c) W0 b) B! I( x B/ D+ F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& |, N; t7 u' h6 s -14 q, j1 q# c M3 E" \
};
* Y% R4 }: [% `1 F1 \- Q- f/ o t; C* b4 Y; Y& D
static struct gpio_led da850_evm_tl_leds[] = {0 y9 j7 E! b5 q2 P% y
{8 u6 W2 a: @3 T: h
.active_low = 0,3 Y7 N8 R# X5 m/ n: i/ ^. s% j0 v3 _) z
.gpio = DA850_USER_LED0,
, _9 E! `: K; F& w V .name = "user_led0",
( b8 Z/ }% Y4 r- z .default_trigger = "default-on",2 m' J" D3 V4 A- G. Y
},
8 T9 H9 I" L+ k# u+ \" M {- ?& K5 ^5 a+ c. x: K% P- |7 u
.active_low = 0,
: J2 S! i. E" o8 ]1 B% w+ u .gpio = DA850_USER_LED1,
' P+ r* O, e8 d .name = "user_led1",' p" S6 O" b+ H# d" w$ j0 W: v
.default_trigger = "default-on",
+ F* n/ a1 i3 L( z },
" Y* l1 M9 q9 B; L {
4 P) c* ~4 r0 B y3 P$ t# _ .active_low = 0,
) [' t& K3 K5 D g .gpio = DA850_USER_LED2,# y; z+ l7 v ~1 l6 ]) z7 O1 {
.name = "user_led2",
. T& {. A$ ^/ b# `0 \8 \7 a# ^ .default_trigger = "default-on",+ j# H6 R( \# o, u
},. }( q) q- C* I9 b1 o' h4 ^
{
- }8 c: ~& _# H$ q& O- k .active_low = 0,
2 `8 F& S1 {1 N) O; ]9 J .gpio = DA850_USER_LED3,4 j( M! u! `5 C+ w9 a0 `, u0 |: o/ q9 a' Q- D
.name = "user_led3",2 b' V! t' Z. C8 H) I
.default_trigger = "default-on",7 B' Z5 y3 g! u7 `$ v r/ F
},1 M0 B, r! T* o4 J1 [# Z4 \* v
};
% x* L @$ u$ v8 ~$ `6 s& F5 j2 T6 V" ^- f; Y8 g; S# p) A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ j6 P7 ?: J$ [$ T" N; V
.leds = da850_evm_tl_leds,& q; W+ U9 ^7 K: A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ v* U; @; k; p: X! g/ j};% A1 V- h8 f* Q$ T/ A, x5 y( _" r
7 i! Q' Q1 u# v" E& v6 |6 ?
static void led_dev_release(struct device *dev); e/ n: }" w0 a( N$ T
{7 @- ? i! J0 N0 W7 Y# W5 l
};
" X2 @: N: H- Y9 G* p; I+ }5 w) P: ?3 ^: z, c9 L
static struct platform_device da850_evm_tl_leds_device = {
& j7 p H3 h1 r2 K) `: J& b+ E .name = "leds-gpio",
" U2 ^0 B1 H5 m .id = 1,1 @- t) m1 x- I: |' U6 F
.dev = {
) z% ?5 I8 O* l: s/ V0 F) B .platform_data = &da850_evm_tl_leds_pdata,9 ]- R" z" @) t/ e
.release = led_dev_release,
0 L! A1 n, V9 e, \& t1 q* Z1 P }
2 W- d; d3 h+ k) r# l};
: r) s0 x! T: G& b1 m* t: f. U7 z) Z3 Y) }. ?) q* P
static int __init led_platform_init(void)
/ d$ h* g/ S+ v# I3 ^{
" t- v1 g4 t) R- o int ret;* H* W4 [3 ]" j% p5 U7 J( g& I
#if 03 N" x" m, W, w8 d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# Z' g' R" F, e7 W% S' R( P- P1 K if (ret)/ P/ V! U% G: X6 P3 a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# O" y7 ~; I& Q4 F5 P! w/ ?# k5 p "%d\n", ret); E2 P. K$ g/ [- c% H2 Y
#endif
" w- D% Q$ V. W8 a( Z ret = platform_device_register(&da850_evm_tl_leds_device);
! s# U {- m Y9 R: J1 U* g if (ret)7 o8 k [; A7 U8 a8 S( F# p4 g- E9 }
pr_warning("Could not register som GPIO expander LEDS");1 J. |" i. |/ |; [8 ^
else$ g) t$ Q4 G K& N- c b
printk(KERN_INFO "LED register sucessful!\n");
! ]+ j2 v" y8 [2 S f* C
% X8 b6 V8 Q. A$ J2 ~ return ret;( g7 s& _- Z1 H1 @7 o1 _
}
# Y6 b) x3 j; C& ], x9 a2 D. g, e* o. r( r' B+ A$ F
static void __exit led_platform_exit(void)
9 V, Z( v4 T$ D" b{- d4 l6 ^- I* P& J4 \6 L& \; u1 S
platform_device_unregister(&da850_evm_tl_leds_device);
; `' P, v8 a8 c+ _4 U! [ p
$ I) u9 H* w' S+ a; L1 m9 F printk(KERN_INFO "LED unregister!\n");
8 H- L- n* b4 @: E b# @, A) N}
6 W- l0 L3 t8 S* u: A2 R+ ^
3 F; {" L3 |) Y" y( q# ]) Rmodule_init(led_platform_init);
% U1 g( m/ k. [module_exit(led_platform_exit);1 ^2 L9 a0 `: T/ z; ?! m$ s
7 a' o+ L t q8 a6 b; v8 S7 r5 n; mMODULE_DESCRIPTION("Led platform driver");
& J3 Y0 U9 k8 C* C; c7 CMODULE_AUTHOR("Tronlong");: H+ X! \: h2 N3 ^( B/ b- F
MODULE_LICENSE("GPL");, V; O( `8 m* s S& b( q
' D0 A' c( R J$ d; E- O( y
|
|