|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# k( F: X8 Z6 V' B2 w
#include <linux/init.h>
* Y5 Z* x" E/ V1 O#include <linux/module.h>
4 R4 U9 v a4 {% d$ u, y) O#include <linux/kernel.h>8 Q+ C! q' y! x, o C* q
#include <linux/types.h>
n) L; ], Q. |) l% ~4 Y1 U6 x#include <linux/gpio.h>
- p1 u3 P; W* Y, a6 q4 W+ u( t#include <linux/leds.h>* [9 A, Q h/ O. x% \) A& ?* ?
#include <linux/platform_device.h>
6 l" y% P! q7 l/ P9 C) p7 N* w7 C: u
#include <asm/mach-types.h>
1 x2 ?5 M! d2 X6 c8 j% k7 N#include <asm/mach/arch.h>
* r! J0 _8 o6 a& ^( a#include <mach/da8xx.h>
" d1 b. y: O9 W#include <mach/mux.h>
5 S' K: L) e9 Q: V4 W' F1 O, d, G5 u1 G/ t$ a" ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); M N0 v/ L! ]# s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), p5 C) o( D0 H; C8 i: P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 ^+ ^/ o+ S4 X) N$ v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! H: q J& v" a/ p* O
Q: ?2 V% M) N' s3 K. B( p/* assign the tl som board LED-GPIOs*/$ d; I, I! E N0 M
static const short da850_evm_tl_user_led_pins[] = {' ^3 ]7 ?2 O" Q/ B6 V
/* These pins are definition at <mach/mux.h> file */
! E% a( c3 `2 C$ ^/ W! M9 i. ^ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) f% A/ E. `2 G) A2 B. b% H
-1
4 X0 y9 A+ C+ _: m# A};
7 a) l b0 A5 Y$ a+ f0 \, N8 }1 `) Y8 e
static struct gpio_led da850_evm_tl_leds[] = {
( F2 T) ]! h4 c2 l% s2 p7 ~ {( s f$ _, r J4 J1 E3 _0 l
.active_low = 0,
" }) j9 r( E' T+ C7 R, k .gpio = DA850_USER_LED0,
% ~ B* k) z w4 P .name = "user_led0",
* G' T/ {3 a& _7 ^ \$ u .default_trigger = "default-on",
' R9 ]2 {3 b4 D },
" A7 A7 m4 n+ G+ E6 V" I {8 q+ d( F8 G* d3 I% Z9 q
.active_low = 0, Q% W% I7 |: K* {+ G
.gpio = DA850_USER_LED1,
* B" Q* G1 ^8 {6 ?! M. O) Z .name = "user_led1",. p0 e7 W; o; y! ^+ v% g! j
.default_trigger = "default-on",
C. {( n5 `5 f& k [3 n },
+ x4 I: b. R6 u0 `% k) c. P. J {' ^1 @3 A0 d. [9 t
.active_low = 0,
* V' t- m* a: q3 H- z .gpio = DA850_USER_LED2,4 S3 }$ v- r1 ^
.name = "user_led2",
7 v; \ h" ?0 y, W: a .default_trigger = "default-on",7 q6 {1 b4 A5 f" ?
},
: V& y, f; o- R$ k {
! Z. b9 r6 x: l9 d7 I .active_low = 0,% T1 r! l, D( U+ k% |) q% O
.gpio = DA850_USER_LED3,; v& u- C" ]1 A3 S5 U9 O1 O- c
.name = "user_led3",1 C" @- w# r$ T, X
.default_trigger = "default-on",
2 {: a5 B# R$ c$ _) R: Z! C },
# }" G+ \6 h t- \/ D$ o+ D};
* x: q1 I- s+ ^+ v, m5 i
2 s9 k4 Y# p9 B- }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* D& I9 W; A; e8 G; D .leds = da850_evm_tl_leds,
4 `; f0 _. K8 K6 L. ]6 I9 m# M( D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' f8 O) m/ E3 l: ?; |
};0 L9 E3 j; @4 p# c
) ~' ~4 ~5 R& ^$ S! @& F% A
static void led_dev_release(struct device *dev)
2 K* H/ e, Z4 G% R, c0 c! C{
6 T9 L+ j! N" T3 }* c; r' s# }9 G' }};
( P+ V8 Y# J# ~3 Z I( ]4 h: O9 ~6 o( U; R4 \
static struct platform_device da850_evm_tl_leds_device = {
1 q$ j0 Z# w2 ? c .name = "leds-gpio",' I& e5 j* V& E |9 l7 K" a8 _
.id = 1,, \0 L4 V& Z+ k: V; c) ]) X
.dev = {1 ^% @0 d; Q" d5 v1 @" h4 Y! r, b
.platform_data = &da850_evm_tl_leds_pdata,$ f& |8 ~5 q" s2 R! T
.release = led_dev_release,; G7 v/ m! b5 \0 A# \; `4 \! p
}) |# K2 C" J3 Z Z8 D7 @
};
: ]$ c, `" J# n8 _2 o0 H+ T; M& P4 F6 |. x) d1 U- `( R
static int __init led_platform_init(void)/ c" @, t: h5 {6 D
{, P) S+ |" ^, m# e# Z a
int ret;
0 W& ?& o! F! j1 |#if 0
- i6 P6 G" j5 ~- I6 y+ J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: U1 g5 W1 O3 E) ~
if (ret)1 u6 V1 S9 Q4 W4 K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# u$ g6 J( R+ P+ d
"%d\n", ret);
: C7 W3 I* I8 K- o% R3 s#endif3 h: F& C8 \! `) k
ret = platform_device_register(&da850_evm_tl_leds_device);( B7 t- S5 Z/ s& ?% g
if (ret)
- I0 L# w+ [; M2 ^2 c- u' f pr_warning("Could not register som GPIO expander LEDS");) S: R" K4 R5 Q9 |4 D
else
& s- p5 V3 S7 G3 ~# O' [' X printk(KERN_INFO "LED register sucessful!\n");
& F7 g, h0 ~ a- [, f2 w! M& ~6 Z6 V$ E' `) D5 w9 u
return ret;6 z2 ]: |6 l9 U- F* w
}, R8 \ z5 f, R# N% n% D5 b% u
2 R1 e6 T1 z P$ [2 g' Pstatic void __exit led_platform_exit(void)5 ` R% F/ }6 J0 y5 {! i
{
' Q# R2 O, t$ \* J2 [1 C platform_device_unregister(&da850_evm_tl_leds_device);& E8 _! Z8 p# \ s8 k
/ K# m# n; p0 ^* C1 U printk(KERN_INFO "LED unregister!\n");
- T+ A- F7 S% i( A( Z6 G}, v0 \( q/ h% i& [
! ?+ }1 l6 a( n' d. b# r$ E8 d
module_init(led_platform_init);6 G( R' i! d& c5 N1 }7 ~
module_exit(led_platform_exit);# a3 U; O$ |! b2 W. d; `
0 I2 L' S+ H3 N- [* T1 J! wMODULE_DESCRIPTION("Led platform driver");, B0 t1 Y1 _: E& P2 A/ q
MODULE_AUTHOR("Tronlong");2 t3 ^4 n2 W$ X! M7 Q
MODULE_LICENSE("GPL");
) n$ z1 ~8 R5 {* V- r8 A2 x2 S- |2 ~9 y3 F! v. s# F! ^4 v- {
|
|