|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ M9 K2 z3 s4 V, u#include <linux/init.h>
8 e, Y8 [- H: ^5 r: E3 f! |#include <linux/module.h>
+ ~. v1 S: y1 L7 O#include <linux/kernel.h>+ h: D& n t- O3 b0 J! K6 o
#include <linux/types.h>
5 l: F5 L' L1 t5 M% ?) t4 ?#include <linux/gpio.h>+ _; ]8 B1 J8 j7 Y" ^6 U; d( l) B
#include <linux/leds.h>9 [* d) Y5 r4 T% p6 k
#include <linux/platform_device.h>
' c/ g7 e# j) A! D0 |; A0 Z9 S- ^ C4 O' ~5 b) a: ]( F
#include <asm/mach-types.h>; R. F, E0 H+ m
#include <asm/mach/arch.h>
: v- A) Z( L* i% }+ J# Y#include <mach/da8xx.h>
% J8 G- {% E* Z; S#include <mach/mux.h>0 K0 [6 v& ~- K% S4 z2 O/ j# S
l2 s9 q- Q" e7 ?, P; K3 y$ W! K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 B. A& B$ @1 W0 F7 H [5 L0 P. ?1 ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! i4 q! F7 r; f, ~$ b" `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" G, G+ _* s( ?+ Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), h' |3 c3 ~& A; N' |) b m
7 p/ h! z/ J8 j4 _' j* |8 f, h/* assign the tl som board LED-GPIOs*/+ q' z4 h. c0 l6 ]8 C
static const short da850_evm_tl_user_led_pins[] = {
& Q7 m& F+ [: M4 B( o; w( O /* These pins are definition at <mach/mux.h> file */: n& N9 p S' n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 e2 y7 z, E& c -1 `; D) y9 U6 Z1 p/ P, P9 V# Y1 z
};
+ m* X% @0 [1 k7 i/ O0 n! B* ^! `2 Q1 f) z
static struct gpio_led da850_evm_tl_leds[] = {1 r' _7 p4 A: S/ ]1 C
{0 J" d0 ~* s* a; _9 ~$ u
.active_low = 0,' p. s' O% I# C/ H: W: `" `
.gpio = DA850_USER_LED0,) Z5 r* o$ S* P! Y
.name = "user_led0",/ M& S% U; p y$ C
.default_trigger = "default-on",
4 ]2 @' ~! W- G6 } },
) e: D6 `' `, O5 q' R {2 {# c/ a) X, n+ }8 J
.active_low = 0,
8 I b1 G" [* |! c. {% S4 X" P .gpio = DA850_USER_LED1,
. Z) n5 S7 ]- @* }6 ` .name = "user_led1",
, w; o7 n- |4 _* t .default_trigger = "default-on",
7 Y7 H0 H+ @/ N. v },' ?6 `, ]# Y) ~7 j0 T( K: J$ r
{
4 ~: C0 M; W0 F .active_low = 0,. U6 w/ ^) P! ] f* [! \
.gpio = DA850_USER_LED2,' I! Q. D3 H; Z+ v" O `
.name = "user_led2",
+ Z: f- P, p" T .default_trigger = "default-on",
5 [9 D+ B; E9 e7 |+ w' p },
' a. ~8 C& @. s! Z) h& L2 Y# t {
. x+ n/ K, A2 k$ r5 k" R' h) \ .active_low = 0,1 a& E. L$ r" m) K, }! Y- u/ v4 s
.gpio = DA850_USER_LED3,
+ V. f* ]( q" `& \ .name = "user_led3",
1 K8 M$ D5 C3 ?! [( o8 @1 x3 b .default_trigger = "default-on",
5 [: M/ e% z# H5 L/ T, l },& t l; o* d3 N6 _" ]
};
/ G9 S2 ?3 m$ ?! c2 \- d4 N d. {6 ^; t$ `4 p1 H* T4 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- F7 e* z) P3 ?0 ?
.leds = da850_evm_tl_leds,
$ M/ ?9 T4 ?" d0 D! a* @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ g& T( h* q1 D# I* k6 l};& }' C! o0 X' n; e
2 a( L/ }0 S( w2 Z4 Ostatic void led_dev_release(struct device *dev)) ?/ }" F+ D& T8 l
{5 [0 v! Q; w' `8 i# ^
};
) P: k* R- O9 v3 v5 u# \. U8 e2 G5 k8 O2 y9 D3 k
static struct platform_device da850_evm_tl_leds_device = {
) Q0 ?( S9 z* ^2 X0 p# d' o .name = "leds-gpio",4 J$ @; ]$ Z1 j+ [8 F. D
.id = 1,/ r6 i) Q Z# B
.dev = {" S# s3 q0 U7 ` Y! E7 J; Y) \5 Y
.platform_data = &da850_evm_tl_leds_pdata,0 s* ]5 n' q5 n, k4 D" \
.release = led_dev_release,
4 P E% }- T. V% g }, d9 u0 T$ Z2 E8 u7 x% P
};
3 x8 |/ X" O+ A- S0 U6 R9 W/ e
) ~9 t& T9 \ S. m+ `1 @" x/ M' lstatic int __init led_platform_init(void)
5 @& }. \: s8 ?! c: c* j9 n{
- C9 {) H& ?/ i2 u* X1 I int ret;
& T: q) {4 v9 R& h# u: U#if 0
4 m7 F W( y$ p' n+ x0 h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" Z* G- P1 D7 S6 p if (ret)5 W. Q& A+ {! j: ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# A! m( Q7 l, N5 n3 M2 G0 D$ J "%d\n", ret);2 O# h* B9 r+ ^# ]& l/ c
#endif$ n a2 n6 n+ r6 E$ @' w
ret = platform_device_register(&da850_evm_tl_leds_device);
" R$ d. f0 |5 w2 O: W% U7 I if (ret)2 T: \, }* g" I! @& n
pr_warning("Could not register som GPIO expander LEDS");5 \" r6 U# u8 Z6 u% _+ p- }5 w9 @
else
5 w" a4 i; Q. [* l1 i6 G" b7 r printk(KERN_INFO "LED register sucessful!\n");
; M D' Z/ q* w. R& P* f, l1 j2 @
% O9 K! O, M: c* t return ret;8 R1 w5 ^1 Z3 u
}1 `1 T# \ M+ N3 X' c. y; I
. f' `6 U, {- G( S2 o4 T; p" }- Kstatic void __exit led_platform_exit(void)
) h' d. l& b1 |3 t{
: ~2 n: X( S! @! z- [/ a- a) i I4 [+ z platform_device_unregister(&da850_evm_tl_leds_device);3 u+ r4 n0 [ t" J
* W! u/ O7 w* a5 p1 H, Q; i% v8 n
printk(KERN_INFO "LED unregister!\n");
$ @- g8 f, l' H}6 c+ E D' j( R. z5 w# I
: D% c- P- ?3 r
module_init(led_platform_init);
* S, v; g( {( V8 o. B4 Emodule_exit(led_platform_exit);
8 n! t. a% R5 J
% }0 b! i/ N! ]' aMODULE_DESCRIPTION("Led platform driver");
+ a: _' w- n1 V0 A' sMODULE_AUTHOR("Tronlong");" J# F; ^' Z9 o7 O/ V# l
MODULE_LICENSE("GPL");
! c& u+ E0 j- R. f5 Z+ q& Y2 J3 l0 {7 v$ {
|
|