|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& _/ H0 q2 q5 ^2 N) E. ~7 a- i#include <linux/init.h>
, q+ b' c B2 a( q) S* N#include <linux/module.h>
' a8 [3 L/ h; O4 L) I5 E% I0 b#include <linux/kernel.h>' w' I# C0 X* G0 a* F
#include <linux/types.h>
( L5 I( `4 h* P% O- N l#include <linux/gpio.h>& v- s, c. e/ b5 x0 [
#include <linux/leds.h>
* X- F6 ? c5 e; ]) j#include <linux/platform_device.h>
4 e0 s9 @9 }5 X+ P- l6 q, u% m# H$ m: ^1 W
#include <asm/mach-types.h>
' e# Z! ^2 \: j#include <asm/mach/arch.h>8 i8 } ~0 \- ^/ j
#include <mach/da8xx.h>/ Y7 Q4 C( j: y/ V: ^. T' g! d
#include <mach/mux.h>" D1 O, D O9 e' ]+ \
& @' Y/ b( e+ t- K; S7 o9 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" }/ O2 A( a* b, Z# Z* K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 z! s6 @) a2 n& U6 u, u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 O$ V5 Q, q4 R1 G1 |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ }! ^# P9 R2 @# Q: \/ O; H1 I% j4 g
) ~ z) L4 C8 t# B/* assign the tl som board LED-GPIOs*/. B$ y+ P, K2 ?6 j) w- x1 ^5 c- t: P
static const short da850_evm_tl_user_led_pins[] = {
2 _. Z/ ` X7 {# { /* These pins are definition at <mach/mux.h> file */
* }5 @) j# Q: S4 ^% }# y# t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% D* J# N( x1 {. W. e- Q9 d' Q -1
) T8 d0 ~/ ]* ]8 C};* Y* U& G( E' h+ |" O2 e: \
9 y3 ?. s8 j# k2 O5 H7 G! E/ F2 x0 X
static struct gpio_led da850_evm_tl_leds[] = {7 `, X1 c" Z. j
{' m" a. L8 t* {
.active_low = 0,
) G/ V3 b( d9 L O4 v7 K4 V; g .gpio = DA850_USER_LED0,
; U& C0 C* t0 ^, W, ?! | .name = "user_led0",9 M3 ]2 w+ O3 N+ x c: H! A2 g
.default_trigger = "default-on",
2 n g: e2 n( x },
$ @1 e7 v- V# t# J {7 m; j6 V0 `2 O3 [* ~
.active_low = 0,
% {$ b4 X" ]2 U: I9 o; }* X7 g' O' w, F .gpio = DA850_USER_LED1,
1 A* a& L9 Z1 { .name = "user_led1"," p |7 e8 z0 o, \
.default_trigger = "default-on",& o( N {1 [ z. @$ {
},
: {0 P4 q8 }( V" u2 R {' d* D# M U b0 P0 E
.active_low = 0,: u* _# T( U R; O p0 d) w Z$ l
.gpio = DA850_USER_LED2,( B. p+ ]* \8 {9 w/ v
.name = "user_led2",
& I/ e E: P; } H( a0 E .default_trigger = "default-on",
9 V. S4 b; ^( P$ P0 B7 m* V2 E8 ~ },
1 d: s0 k% S" Z8 e4 ]$ ^ {
) q3 A- E7 x# i% h .active_low = 0,4 T6 y E, ?5 R3 L K V
.gpio = DA850_USER_LED3,
5 w8 \9 Y% s' X# F0 S .name = "user_led3",! A6 K4 z9 ~' l5 r1 a5 b% R0 l! `
.default_trigger = "default-on",0 D$ ?( _$ }0 ]
},
0 M! X5 b1 f* x" p};" G( N3 D* c% \1 C5 T. P
# f- J. `1 e, i- Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ L1 x6 M8 z1 I' F N( c; T( _ .leds = da850_evm_tl_leds,
2 p- ^) D8 V$ a6 t6 y/ @" L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' Z$ I& Y7 Y: |
};' W8 x4 r" _0 M: y1 }
+ n9 K1 _( a: R' P" r# a$ K3 ]3 d
static void led_dev_release(struct device *dev)
- l- N/ @- @: g! z) e5 n{8 l* v2 ^) R' |% _. u" w% N
};
: i9 F9 M' p" g! B
8 @- m$ b& C6 l6 z* p* [static struct platform_device da850_evm_tl_leds_device = {: D& M. K" S- h: K
.name = "leds-gpio",+ i" p6 u: C/ s: |
.id = 1,
- j4 C# H0 i3 `" g# R8 M .dev = {
/ _* Y# V: K3 C$ u& F# R* Z .platform_data = &da850_evm_tl_leds_pdata,3 k1 p- G, n' w
.release = led_dev_release,
. X. @, s6 }* @1 p* r6 @& G/ Z/ `/ K }3 y. `" O% G6 |
}; E- s, t. g c
A; X: h2 m. Z4 O+ Z2 Y
static int __init led_platform_init(void)
$ I3 ^3 a4 f3 a5 a2 `9 [" O* q{
2 N8 w9 R6 a5 S# @6 j6 F int ret;
5 |9 ?) `2 ]7 M9 m#if 03 r" m% w/ l3 {' Y* d5 k7 J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 N6 ]6 O0 j! ~ J
if (ret)
W3 l7 b3 H! S l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" q- @' b% d \; O9 ~# p
"%d\n", ret);& @! a8 i' @- D7 Q k
#endif
6 g* d$ {6 c) V1 f0 H9 {& J# d( J: S ret = platform_device_register(&da850_evm_tl_leds_device);' r6 l4 `* _: n0 e% Y) Z
if (ret)
3 |2 S! o9 v9 I. e% C* C, ^ pr_warning("Could not register som GPIO expander LEDS");
% K8 a$ _: D V: Y, ~ S' V) _ else; O# y: \4 V: y! Y" f
printk(KERN_INFO "LED register sucessful!\n");% T7 [- ?' o: y& g
. R! i1 g# |7 a, `' V! H+ Q0 a# p% z return ret;; y" L- q6 v' Q) i9 a
}- T1 u6 I( r$ \* y% g) C
% ]7 O9 a) {+ U/ J: _
static void __exit led_platform_exit(void)2 I B D( n8 ~$ y- U6 t2 S6 c& e9 H
{5 ?4 Z6 f. {" G. S, |) O) u" m
platform_device_unregister(&da850_evm_tl_leds_device);
, D8 L [' \7 N, \
7 v: g4 j5 M* @8 g ?; i4 y( l printk(KERN_INFO "LED unregister!\n");+ P' X1 {. @: R& U& G2 S/ w7 K
}
8 i$ n+ T' R) e7 b4 `& m; d N. x$ y1 z
module_init(led_platform_init);' f$ z/ L8 H4 F7 n8 c
module_exit(led_platform_exit);4 P J& B a6 c! q' P5 _% M
4 Q: P! u1 q3 |4 p: W9 z! AMODULE_DESCRIPTION("Led platform driver");
( G! c2 ^) W5 d+ jMODULE_AUTHOR("Tronlong");9 Z7 ^4 x6 r& t! k. M) Y
MODULE_LICENSE("GPL");
& h! j [+ K5 ~! r* r: S) _" b0 D
; L, K4 P# j. G2 Z8 \: M2 ^* Z |
|