|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 k; S# j( J9 d, A* ?; U#include <linux/init.h>& @. A, I7 g" b D1 K7 A, _7 Z) ^
#include <linux/module.h>
% C9 `" I; I. J% B& T' ]2 y2 K. M#include <linux/kernel.h>/ y# E' ] g: l# T& @8 H
#include <linux/types.h>
) K; F; G1 m2 d#include <linux/gpio.h>0 _# ~; v! t4 S1 i% w
#include <linux/leds.h> L. M7 G8 f) s* c: y @! B& C
#include <linux/platform_device.h>8 H- a0 P" O8 K2 r6 `3 V
8 y- Z2 D' |5 w4 V0 C% j! ~% y
#include <asm/mach-types.h>6 e! f [3 I, h# N7 p
#include <asm/mach/arch.h>
5 B' X" `% c; h* i0 Z& g+ I#include <mach/da8xx.h>
9 W/ D+ h: ^" F- ~" t#include <mach/mux.h>" U$ x5 T) {( G' j
6 U; v9 \+ ?0 C8 H& t2 P- W5 R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 e" |/ }1 g6 g. W0 L5 P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, p9 e% I& s/ E# ]! u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* G7 M, m4 j- M" B; r' Y$ w$ e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 ?8 l" C8 U7 Z7 l& C7 Z% @( d
2 X7 x4 V7 _* X3 n6 w' L/* assign the tl som board LED-GPIOs*/) ~) q3 T# L6 p7 R9 L/ i! [
static const short da850_evm_tl_user_led_pins[] = {
* ]; t: P# B8 C! A /* These pins are definition at <mach/mux.h> file */, Z# f' x) q- J" O+ F# ^8 ] A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 z8 D& v/ U8 }! }+ o- X -1
7 s. l+ Z8 i" E0 w};; s$ i b" x" f/ f! @7 a9 a
, J5 w s2 H( @7 a7 }0 ?% n+ hstatic struct gpio_led da850_evm_tl_leds[] = {/ _2 ~6 z. o3 x& u {- B$ C
{; V* @3 d! j. t( j0 y
.active_low = 0,
$ Y7 }8 c' o$ X5 }- A5 r4 }/ E9 O .gpio = DA850_USER_LED0,5 x* b; n0 y& z( w0 n
.name = "user_led0",
* B( i' W. I& J& [$ p .default_trigger = "default-on",
9 ^. [" P) b+ E },
5 b f; a1 C* F' q+ L% E# k9 B' n5 H {4 b0 K7 q7 {. K& l) e" ^
.active_low = 0,/ B& b, M- u3 F7 Y% E. o
.gpio = DA850_USER_LED1,
6 i3 a, U' K# s2 n: ` .name = "user_led1",
" \$ Y2 C0 _# w7 D9 P .default_trigger = "default-on",5 z( p: ]2 Q' j/ b. K
}," H0 u Z3 K0 P! A" o) F5 A, m" @
{7 W8 s: _4 L; ]1 A
.active_low = 0,
* q, F. W6 j2 q. ^ A3 r .gpio = DA850_USER_LED2,
/ C: h4 C: V" Q5 q; I+ f' P7 t .name = "user_led2",
/ y* M5 ?: Z% @3 a% x .default_trigger = "default-on",
$ ^+ w2 z$ M( m% ~3 Y* w },
( |7 O% U# Q- i {
' O( f5 s' u/ n .active_low = 0,
. N! o* ]# J5 T/ ~# ]. x; J. O .gpio = DA850_USER_LED3,
- C( x7 e- B) k+ a% e( t4 e .name = "user_led3",, A- j" `' g4 f4 g$ W1 l) h! T
.default_trigger = "default-on",0 ^5 Q" V9 F2 ]! g V8 F4 @
},
4 c# C3 H" S: _" C};/ @* N3 B+ C4 g1 S U4 } {
9 w$ {" r- m; O; v, R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ^ V0 ?& }% c0 v$ g* f5 T$ F' }0 r .leds = da850_evm_tl_leds,& V$ N" O, N' `6 A% z- `& o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: ^% {$ |8 A8 X& s# C+ J* {};* q' N2 V! K1 N! y0 b' b6 a
/ I: c) m" I+ [7 Z
static void led_dev_release(struct device *dev)
2 A+ l7 a% ~5 |' Y1 L- |0 F{$ |) h+ D$ k; ^7 Q$ @% v. t
};/ R F/ l; n# I$ `
! N3 X* R. @2 g# X7 c* q1 Istatic struct platform_device da850_evm_tl_leds_device = {
$ K$ c: e/ T5 I4 f$ k& H .name = "leds-gpio",
% c8 V: h0 I# ` .id = 1,
" E+ I2 {* z$ c8 S5 v .dev = {
+ H G9 H' m2 ^9 Z$ g .platform_data = &da850_evm_tl_leds_pdata,2 \3 F; X; C7 A0 i
.release = led_dev_release,2 f3 O/ @& V( y0 j
}
7 q# R2 J. P9 G- ?, B- r4 c};) ]9 E* X! {3 ?! x" O- F
6 { ^& ^) q7 R$ {* f$ ~static int __init led_platform_init(void)
; c1 r& G& n& K" @ {! `7 p# T$ X{8 D1 r$ P- g; l- Z m0 O. n
int ret;2 L# Q. I% v; z% v
#if 0
, t8 \9 {" i J2 y5 H4 Q# `' W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ u, u# N2 k' p. g
if (ret)- \& }2 _7 w( t9 }) N% u) W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ e' D& L0 e6 v+ z4 }7 \/ o7 C7 w" Z
"%d\n", ret);
- N2 u: y) e' }' f0 o7 g( m#endif
, y3 l, @( m, X( V& F ret = platform_device_register(&da850_evm_tl_leds_device);+ P' Z- c! t8 o- y3 J: |
if (ret)0 m' [3 M) v: T% u0 T
pr_warning("Could not register som GPIO expander LEDS");
2 ?! _7 x/ |/ c* h8 Z else$ |% O3 w+ \) l6 s1 c
printk(KERN_INFO "LED register sucessful!\n");: r9 T! ]4 `4 Y5 \9 F
1 e6 M5 g W+ E9 t3 ]0 {# } return ret;; O2 T+ S3 T) X$ L5 t# H
}
+ K3 i, m* A) k5 c3 ]. w, K0 V( q' [+ G$ Z5 P; i
static void __exit led_platform_exit(void)
" ?) G K5 `' ^, [* m! c# g{
1 g7 P. F. D' `5 v8 ?- \ platform_device_unregister(&da850_evm_tl_leds_device);( x* a4 R0 T' ]+ t7 O, F y
+ W& B) ]3 {& ?! i* b* ` printk(KERN_INFO "LED unregister!\n");
3 m; ~6 }1 T4 ]' z}2 P% ^. k; Q j
3 D: F. v1 L( O) ^9 z" z
module_init(led_platform_init);7 q6 O, m h; L" c" E5 ~8 ~- D
module_exit(led_platform_exit);
/ Q9 B+ O5 F- x
+ e" r" E3 [0 D$ _5 [MODULE_DESCRIPTION("Led platform driver");( b' |2 k5 A9 a: d6 l6 @% b2 | r
MODULE_AUTHOR("Tronlong");4 ]. r/ h3 i) {+ s$ a+ I
MODULE_LICENSE("GPL");. f$ b4 |0 s( P7 e* I' E8 A" ^+ a$ f& P
# N8 R5 ^# v, P/ C |
|