|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" }4 u* o0 e. L* k5 I; t! K
#include <linux/init.h>
& s5 o4 v3 C* A* h2 b% l! o#include <linux/module.h>, R1 t( Z: c5 A* [: r
#include <linux/kernel.h># l+ W0 @$ j& j- n
#include <linux/types.h>! A5 H" @4 r c; J! R% K
#include <linux/gpio.h>) e' s* _. O; x+ v O+ n
#include <linux/leds.h>
' w7 K* t2 Q4 `( |+ U6 I6 @0 r#include <linux/platform_device.h>
! }1 C+ h% m; X3 q" Z: S( J; q# r# x+ E
#include <asm/mach-types.h>
* w) O' r" f: J, p$ H; z2 e( G#include <asm/mach/arch.h>3 [7 s* A$ x4 r, X$ p Z7 [ Z! h# P
#include <mach/da8xx.h>
$ x% X" r( J0 H; ]+ O% m#include <mach/mux.h># I4 E4 Q, ~ H6 @& Z: q
. N3 v* P N% \9 Q" ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 s( Y, R! g+ y( X6 @/ F2 ]4 m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) F/ y2 X$ Z3 D
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 N5 |# R# l! O6 _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" ~" r9 E. O2 Q. p
9 x' a, p8 M& `$ w/* assign the tl som board LED-GPIOs*/0 \) M4 i4 @% `: { p
static const short da850_evm_tl_user_led_pins[] = {
0 L; \5 C, I3 i$ Y /* These pins are definition at <mach/mux.h> file */
6 N/ @8 p' Y0 |$ M, x6 M# [) r DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 H5 W% n* I8 D3 B o _& C
-1( m1 ]2 Q& M" E
};
( n5 G3 Q) i6 u& A" t! P2 V6 e/ h1 i" N
static struct gpio_led da850_evm_tl_leds[] = {
! S4 x4 j2 F! E- K {
0 @! ^! p2 j1 ] b! u .active_low = 0," z1 E, m y* R' {1 O
.gpio = DA850_USER_LED0,, ?/ t" ?/ m( Z3 x0 t2 T* c
.name = "user_led0",
0 |/ v5 ~' b2 |! S# J .default_trigger = "default-on",& |, q' E; g$ J
},
7 }: n! I1 ?2 h, Q {
& {2 R7 o# g, z# G .active_low = 0,: M; m$ v+ H8 ]& v1 B. d) |
.gpio = DA850_USER_LED1,
& P. K" ~# J0 V" `9 w* \' r .name = "user_led1",
) A/ Q. D [2 K- J .default_trigger = "default-on",5 J; H5 A4 y4 E
},
% ?' Y& S5 a# A5 _$ K2 e& { {# K1 G* @4 ~5 O6 ^) p, n
.active_low = 0,
8 u5 b& {5 Z* e2 B# B; j .gpio = DA850_USER_LED2,8 }, y. X+ S# ~5 H n5 T
.name = "user_led2",
; H1 x' y( ~7 F( Q! _3 l .default_trigger = "default-on",
: v. [9 `2 u% ]! a3 N& ^7 V },
$ D# U% O4 Q! n5 ], [& ] {- l* ~4 H3 L: \4 [" P( a
.active_low = 0,
6 L# W. ~& r1 N8 R8 i7 [5 k7 [ .gpio = DA850_USER_LED3,1 L, Y1 \8 K& J- Q, p, G
.name = "user_led3",8 E: P% e& \2 m
.default_trigger = "default-on", f4 c. E; t |4 Z) q& e# U
},9 g e+ v, T% n- ?' l
};
' q( _( C& g& j, v! u
+ x# m& |% S7 p7 U6 P& ^' Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 O4 Y* J9 x8 c/ n
.leds = da850_evm_tl_leds,! [7 h1 B% p9 {! C& ?$ t2 @$ \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 m% s/ y" b# d' ~$ u g% W8 Y+ G
};
5 r& I5 T' H% d* h! {7 B" `8 ^9 s) s: a
static void led_dev_release(struct device *dev)' p8 H9 A+ n S0 Z
{
1 X* B" t$ E( {! G9 m};/ n. L i: b# }
: E- u: u! P; D. Y8 }8 fstatic struct platform_device da850_evm_tl_leds_device = {
" }2 ]$ r3 w0 M, Z) R .name = "leds-gpio",
+ Q2 @) _9 J5 O, Q .id = 1,
- b% v5 {4 \2 f .dev = {/ K3 I+ W1 A! F/ e
.platform_data = &da850_evm_tl_leds_pdata,( ?# O# C6 o+ F: `
.release = led_dev_release,
0 D. O8 Z( a# l6 q3 o. {8 }/ ` }# g9 q2 {% B4 I7 @: L$ i
};' h; v$ r; X: R' o( v3 Z* {; Q
9 F* e8 o- W- l, d5 d
static int __init led_platform_init(void)# f- T) y) {* q) u
{
, G1 g1 h8 l. ^- A int ret;
( r- y8 W6 x+ N. X9 H* |: t#if 0( b( ~( R, `2 l" J0 ] l" N
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) s% Q3 e/ Z; D. T# u
if (ret)9 a- A* d6 ]) d' U( c/ U) W @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; G2 p2 o: j- L: b5 O1 L "%d\n", ret);8 K1 o8 s* M- ~ q* I1 @8 ?
#endif$ e6 l; U7 r+ G* i# M: Z1 L
ret = platform_device_register(&da850_evm_tl_leds_device);; E, S4 S) F& c8 K( m
if (ret)1 W' h* E% f# n- Y
pr_warning("Could not register som GPIO expander LEDS");1 G+ D& Q5 _6 k, Q, }
else
7 W; f% z6 g! r printk(KERN_INFO "LED register sucessful!\n");
]1 @+ S4 X. f9 [. X
) d4 t" k5 O" d; l return ret;# _5 I1 F6 {, w$ l4 D/ K
}! Z3 A; V3 X' q6 _1 x5 o
9 {7 `+ ] t* S$ F+ n! O3 P6 n
static void __exit led_platform_exit(void)7 @. Z7 B3 i+ G; m( i
{
9 [ K' ~" z7 r y platform_device_unregister(&da850_evm_tl_leds_device);
9 f. j. j2 B9 Q* W) o4 _8 u# n& r0 Q& L' _6 {7 I
printk(KERN_INFO "LED unregister!\n");
# p1 |6 X/ `1 J2 I/ O3 p2 z2 V}" m5 N$ x: K9 P! J- F0 d
3 x- P, {! N1 \( d9 I2 Bmodule_init(led_platform_init);
7 f$ y2 G, l* u( B. Zmodule_exit(led_platform_exit);/ U- Z a2 u' I" v
% r4 t" B4 ?6 I9 S" f
MODULE_DESCRIPTION("Led platform driver");" ?9 n" z- e: k( ?6 v# m
MODULE_AUTHOR("Tronlong");! o3 L# m _* G$ ^; f+ E
MODULE_LICENSE("GPL");5 F0 E6 T3 l0 G+ C: |
; w/ l9 |" m8 i8 z |
|