|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 F* F/ w5 g, I# N Q; G3 l#include <linux/init.h>' [9 \; y U! Z } q) M: D s& `
#include <linux/module.h>- t" j! f7 D& g+ X* ~
#include <linux/kernel.h>
4 J3 f# {9 w2 J8 H3 I3 e#include <linux/types.h>
: _" J2 M8 B9 W4 J#include <linux/gpio.h> a% S( R7 }* v$ l3 R9 p
#include <linux/leds.h>2 { q4 ?7 P L3 T4 _
#include <linux/platform_device.h>9 r" M9 V% h9 Q" ^3 A2 u& ?
F/ q5 w% o9 s
#include <asm/mach-types.h>7 m" e, H, _' e- e# i# p$ o
#include <asm/mach/arch.h>
+ k1 y9 g: S2 \; b#include <mach/da8xx.h>
* v1 Y3 U7 |, H* C% j, n$ a#include <mach/mux.h>8 e r. C$ L2 x2 M' ? q7 X$ b7 O4 w
_, U6 n6 y9 |& l* {3 ?- R+ F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% K/ }7 J: e7 H. y( M3 c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 G" y8 c& c% _$ r8 d# A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 V1 |; }. N7 @* z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& O* Y( g9 ^% |4 P) v( l3 M: ?
7 w( o; `$ r" N1 g0 U! Y/* assign the tl som board LED-GPIOs*/
/ i$ K C* v0 T/ N; j" O- }static const short da850_evm_tl_user_led_pins[] = {
& Y% z/ i' `- x2 V /* These pins are definition at <mach/mux.h> file */
9 J, m0 I- D. u- u( a0 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) w+ _- K; p, C% b0 Y -1, t3 D2 [; |( P* f" L4 [
};& _. z3 \6 M6 i! |
5 D% m6 X! b! V f6 V8 U$ ]static struct gpio_led da850_evm_tl_leds[] = {6 @$ r! B2 m3 v7 t
{. V/ ^( S$ n! [9 ]9 g! {( O! R
.active_low = 0,& w$ p4 M5 w# i! M. h: Y
.gpio = DA850_USER_LED0,5 L- ]4 R: ~5 ]* \- ]! a. L6 B
.name = "user_led0",
9 C6 N* n" W4 m( U$ j; Y .default_trigger = "default-on",
: Y" l. z3 {) r/ G% Z) b# r& r },
! j5 y- T; u) b b( V$ w {
, c# F! M: ]- l. E5 E1 g5 _9 ^0 f .active_low = 0,7 p- W6 t- V/ S' M3 s
.gpio = DA850_USER_LED1,
( v5 n& B* `# s0 r .name = "user_led1", b4 B4 z. A) ]% D
.default_trigger = "default-on",+ J3 ~4 Y8 m# x+ \- ~! q
},
* B3 ^5 c" c* S% Z! d' q {
; Z. u6 p5 @5 P9 Y' @8 w; k9 ?) n1 y .active_low = 0,6 Y* l8 } ]: J4 ^: w" R% h
.gpio = DA850_USER_LED2,
: W/ b* q( n, r7 ]7 N& l .name = "user_led2",) e. U- U- v) P; S
.default_trigger = "default-on", k$ _+ r+ J! f, [9 G' f3 O
},* x. E9 \% f. B3 }9 Q7 k& W
{ `0 y8 K- Z+ x# j' s
.active_low = 0,
- H: q4 P# s, B i: { .gpio = DA850_USER_LED3,
: ]$ u) ?( T3 C- X, i8 m" I .name = "user_led3",: N: G% m+ S" N. ]3 C" Q& B
.default_trigger = "default-on"," j) ?! n# J- J5 p ~* G5 u! U
}, _: T( a7 U' r0 ^/ {! i' p8 s
};
: ~9 y+ B, K% Z# L1 {% z& d# Q' u+ o$ Q/ E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 E3 D5 o: x5 i2 G) n+ _! ? .leds = da850_evm_tl_leds,1 p: H* y' ]% K0 c: r0 o+ h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ s4 F6 P4 g) @' U5 e
}; E% i! k& H) L9 M* K7 C2 d. y
6 I0 m D3 g1 a/ h# ostatic void led_dev_release(struct device *dev)9 ~+ r# z2 c4 o2 M4 w% O
{* l9 j7 O& |! b _& g K! ]
};
! |! V% L$ t7 ]* ?
: d- Y8 ^/ b- \0 K# T$ Wstatic struct platform_device da850_evm_tl_leds_device = {
) [& {4 b$ H8 f: w- d .name = "leds-gpio",
3 k" U( B* S8 e. m6 e .id = 1,% v# Q2 k7 o0 L8 p" A' W/ H
.dev = {/ V" L9 \$ R) s7 s3 W
.platform_data = &da850_evm_tl_leds_pdata,5 L9 u/ E+ g" {* Q! _! D
.release = led_dev_release," h' x5 U# p0 i+ A6 A3 b
}5 e6 O. E! |$ g/ z# O6 I# ^: C, z9 I' b
};
9 u1 E- R% |+ F1 [
* G5 U- Q I3 ~ W/ mstatic int __init led_platform_init(void)# ]: z& \. [4 {0 F+ }0 v! F
{
% o g6 q# f+ H5 { int ret;; x1 p: P" D1 J$ S
#if 0
+ C( \2 a: H# r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 ~0 s- w$ Y( ^% w+ L+ n) r0 n
if (ret)" e9 K& j" Q' K+ h' W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' W. O1 h$ ]) u9 C6 h6 V4 w* v
"%d\n", ret);
1 x; ~) {+ G. m6 a0 M#endif
+ j2 ^6 {& s2 P7 r ret = platform_device_register(&da850_evm_tl_leds_device);5 p- p$ ]" G3 q/ J. p& S# z
if (ret)& k& D8 H) N3 _% T3 o ^. ~
pr_warning("Could not register som GPIO expander LEDS");; {$ y, p- ?$ k) [+ ]7 `+ a7 y
else4 g& Z# ]$ r3 n0 C! F9 z4 b' c$ L
printk(KERN_INFO "LED register sucessful!\n");" i1 M4 c$ K8 O+ a. l6 m
+ C. Q1 k& O# E, J3 y# i/ x) B return ret;
6 e, K S9 ~0 _7 f}
+ _8 ` y8 Z& R& \2 l2 u4 e! z/ @; T; v1 o2 T; D6 I
static void __exit led_platform_exit(void)
% Z/ J5 w0 D1 L8 h{
8 f" ]* h' }$ O0 I! L8 C platform_device_unregister(&da850_evm_tl_leds_device);! O& o% P/ ?& Z
a; G. @2 g$ ]: K+ | printk(KERN_INFO "LED unregister!\n");. a; N. I: U: Y, P" f
}
% `) A7 r3 c6 R* B- h8 P/ k% q4 p
module_init(led_platform_init);6 Y* ]4 ?, t9 e; {% C4 |
module_exit(led_platform_exit);
7 R' z! v# z. l
% ^) c ]/ b/ M ~MODULE_DESCRIPTION("Led platform driver");
& I ], o2 ^" qMODULE_AUTHOR("Tronlong");
7 j7 w2 v" C( Y# G' ZMODULE_LICENSE("GPL");! N/ F5 `) I% ?
: L6 R( z! i3 f) \2 g
|
|