|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" N2 _) ?3 G9 {/ v5 Y
#include <linux/init.h>' ?3 F* ^/ h+ q, T( |4 X( h! T
#include <linux/module.h>/ {7 k/ c4 V* F
#include <linux/kernel.h>/ J, d5 r3 q8 Y: `, x+ c
#include <linux/types.h>* E9 R" W4 o7 F- ?$ C
#include <linux/gpio.h>& h$ V- z, s# y
#include <linux/leds.h>5 T7 S7 F+ [4 u3 K/ N+ b
#include <linux/platform_device.h>
8 _; f: u' ]% {" Y+ {" b
; ~( ^3 u: D5 f#include <asm/mach-types.h># D4 C# U$ Z4 e7 e3 O2 C
#include <asm/mach/arch.h>
& v' x* g ?: e, A3 M#include <mach/da8xx.h>. r0 b3 U7 H! k# m6 ~0 z2 B
#include <mach/mux.h>
' T1 l: s; `* {3 K) F4 `9 c' j" b4 F9 L1 Z* {" {. U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& w8 o( n7 K" U' n) Y& n! Y& o) ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ n. {/ i# U' Z' T; R& _3 i4 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 p; ?/ z, _+ n3 N, K% w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ a& y: S, V2 s3 j$ k( Q! o0 Y# P% l6 ~; ~
/* assign the tl som board LED-GPIOs*/' P6 q, g- _ v% s8 I
static const short da850_evm_tl_user_led_pins[] = {
: p4 H5 ^9 F; U0 \ /* These pins are definition at <mach/mux.h> file */
% H/ M; o4 U U: P7 a9 v+ r, ]: ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% ^4 {$ c6 L. f0 K9 K5 ? -1$ C- x* ?, j7 [6 m- p
};+ U" r: R5 z G( H) B6 R
% g' I# O# K# d
static struct gpio_led da850_evm_tl_leds[] = {
. d# q% u' x z2 P$ N {
0 h9 }" o0 l9 p .active_low = 0,
: B$ z9 ~/ k2 G2 R+ L$ `) T, o7 f .gpio = DA850_USER_LED0,
6 J0 i( E" I& D" x$ k .name = "user_led0",- [ t' y4 V+ x3 i3 U. u& i1 i1 V
.default_trigger = "default-on",- r5 V% \7 Z/ b6 \7 J8 N
},8 c0 t' A) f4 I5 C9 h2 y3 z
{
5 j, K# L1 ^& X .active_low = 0,$ K) J# P e. q$ i- S' l
.gpio = DA850_USER_LED1,
1 J" K1 w% u( [1 C5 C2 V/ b .name = "user_led1",
8 K) [: _( S0 O B% s .default_trigger = "default-on",
* z- [' P* c3 D: y },' s: `* z$ M" Y, b0 I/ `, {
{$ [0 l/ _3 E4 a! ~+ }- P& f
.active_low = 0,* A, @. T( T! Q' s0 ~
.gpio = DA850_USER_LED2," q$ K: a1 @# L3 _. t; m5 K
.name = "user_led2",; w/ D% o+ C) @
.default_trigger = "default-on", @, J! A! Y9 a# P" W+ C2 ?
},# Z' k% u( g, T$ c
{
8 a9 H7 h& w- B: A' ~ .active_low = 0,
& d2 h2 U" w4 K6 G4 B `9 _, \' g .gpio = DA850_USER_LED3,
$ L" \) j' R8 _8 l* J .name = "user_led3",
& u' z+ M- [7 S- d4 K# i+ v' K .default_trigger = "default-on",
, u( }, R8 i/ E1 b+ r3 l },
* O" E- ]5 t+ q3 p+ G2 o' [: l# ^};
, E& j8 S$ f, m: O2 m+ ?: j) m( X6 V1 U# Q* p9 \/ l8 M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ ~! k+ d9 a) l1 b! D/ U$ v' ~ .leds = da850_evm_tl_leds,
- x' g# B, l& L" y& D" |8 k1 _2 d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% u% V5 A$ ^5 ^6 \# |- Z' t
};8 y C1 g$ _" N( a
9 T `$ d0 _/ tstatic void led_dev_release(struct device *dev)
$ S( Z2 I) n1 q% s. x5 [{
% F' v0 a/ [5 A3 d};
2 ^1 j; V4 T" \
2 C7 j: q. G8 n: ~2 L' \1 pstatic struct platform_device da850_evm_tl_leds_device = {
9 I: m' N2 h- `1 B2 R .name = "leds-gpio",
7 y! V" @# E* A% y .id = 1,
/ ]7 m; D8 G8 g- K0 a9 \ .dev = {, e% N" c0 Y6 r* I
.platform_data = &da850_evm_tl_leds_pdata,
# ^- } ~+ T" c d7 R$ o1 W .release = led_dev_release,
: N" B( R) V. Q3 M# h }- c7 S' s8 I" U1 D3 a& _* i' G+ }& I
};
# E0 J |% R' h E, h: H+ z) @( ]
1 q2 O5 y( |, u6 c5 Sstatic int __init led_platform_init(void)1 d6 _' B5 z, ~: c S
{" Y: r+ L$ w6 c" k: k+ m
int ret;) a. r4 R( _ @
#if 0
2 X0 M, x; j% Q7 F1 a5 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" R3 d9 }1 D% U
if (ret)
4 s2 c9 {# i, V6 z4 L4 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 _% {: ]: F& S6 ~9 l3 @. @ "%d\n", ret);4 J( }/ a# ?& ^" ~; Y& d) W
#endif
* s; u, D- ` E x- X ret = platform_device_register(&da850_evm_tl_leds_device);2 X. [5 c* l" e0 f6 u& i$ u
if (ret)
p. @1 Y. e! u9 C+ T' E% v/ X. X pr_warning("Could not register som GPIO expander LEDS");
6 g1 _+ w' S. K else" A4 U, d q" g( {. a) s
printk(KERN_INFO "LED register sucessful!\n");. D2 B4 r9 t! y2 K0 d# a5 b4 `3 h
+ o. t& m2 b8 e/ H4 Y return ret;
1 E X) R& H1 i}: P8 l; E9 z6 ~! t2 b4 ?0 ]
) ], K! ~: t. `# y- \9 l8 i6 }; w
static void __exit led_platform_exit(void)" @* h' c# ] ?/ w( R
{
6 i u0 b' D; N platform_device_unregister(&da850_evm_tl_leds_device);+ ?0 |% D% q$ D0 T$ q0 D# S
! n7 J& p5 E5 [6 R' g `0 z printk(KERN_INFO "LED unregister!\n");7 \( ^8 n/ `' x
}' N# M: ^( |) e. n( ]
) F0 `# q3 E( s' {' P% {# k5 q8 k+ t
module_init(led_platform_init);' {7 P, x9 r" L& H: |1 h. ~
module_exit(led_platform_exit);% Q( [/ f* e' O v+ G4 b
& b7 D6 U* f( S1 I- ?MODULE_DESCRIPTION("Led platform driver");) X) l( e% z. x( Q3 {
MODULE_AUTHOR("Tronlong");
5 L, N* }9 W, A4 H) z% N+ OMODULE_LICENSE("GPL");
: f2 o, m a9 g
2 a( l2 O9 d8 ]1 ] Q9 c: c( c6 F4 @ |
|