|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- _) o4 }+ o; Z( c: k
#include <linux/init.h>
2 ]& h0 r7 G0 t8 v) n. H- l#include <linux/module.h>* D. X9 Q( k" t3 X0 d
#include <linux/kernel.h>$ G% m4 q0 [9 R: r
#include <linux/types.h>
& z! U: p' u5 p. f" ]' n#include <linux/gpio.h>) v; m. b3 ]; }
#include <linux/leds.h> s( ?! e& e; z! D
#include <linux/platform_device.h># I; q3 k3 i" @& @* }
* X# l* M* R+ y
#include <asm/mach-types.h>4 |. e' E% ~1 f- B
#include <asm/mach/arch.h>1 ^% Y) ~0 o! \3 M% C
#include <mach/da8xx.h>
3 a* P6 T" E6 h/ k- Q! i) i#include <mach/mux.h>
2 l7 j8 B( j; P+ M( w
+ a& Y7 X* x/ b0 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% E; X- T8 ^" @- @& @( \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) i' M0 v1 Z- T6 ^2 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 m$ X, c7 Z+ l% x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 M$ ^- K0 O3 \- G
0 U. u" j3 U. ~# ]/* assign the tl som board LED-GPIOs*/
" u9 p N$ G& P. z7 @static const short da850_evm_tl_user_led_pins[] = {7 a9 ~0 v) ?$ w6 @
/* These pins are definition at <mach/mux.h> file */
( G- K3 \* h4 u. j3 A! o9 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ W! H) @. O5 O1 N) H. M# Q2 e -1
; N/ Y1 _( y( k8 q6 m9 |9 ]9 H% W2 @( Q};, h4 N6 ]4 b1 D% L7 X3 J( h
- y) a8 ?7 y7 T
static struct gpio_led da850_evm_tl_leds[] = {! c6 O( B, ?, [1 c8 B j% B e
{1 K/ K/ I' j7 D) R9 y! w& f" A2 G; W1 _
.active_low = 0,' k' L0 H3 S" j% w5 h! W' g
.gpio = DA850_USER_LED0,
+ L% B' P! X# V- ^# y .name = "user_led0",
% f/ i# G+ Y/ W; |, b; t F$ X1 k .default_trigger = "default-on",
2 L; B: I0 |# a6 A. q0 i b },& u$ I0 N7 R2 }% J7 Q6 _4 I; }
{
- n0 S0 B$ }, \6 t .active_low = 0,
0 p8 V& |4 m ~. f2 t" \ .gpio = DA850_USER_LED1,& W6 q6 _5 r2 A: I# c# {& K
.name = "user_led1",! q# q5 ~2 [+ v
.default_trigger = "default-on",
! L3 _! w/ z" D0 s- ]) b+ d5 T1 @ Y },/ W" v* V. `& h6 D7 {
{1 G! g& ]2 V. M" w+ ]5 J w+ R0 c+ r
.active_low = 0,8 U8 Z9 T, a% u
.gpio = DA850_USER_LED2, ~4 |) y; o: v& g( S4 D& ?
.name = "user_led2",
7 d a+ x3 Z% ]2 A) x .default_trigger = "default-on",
+ d% ~$ B3 T2 X$ H& B% _$ F' p6 i },
. q, V: W- T$ D& a L2 r {2 S4 {& O3 `, Z3 n* `- @
.active_low = 0,/ J9 c4 H- Q( S# U
.gpio = DA850_USER_LED3,
* b8 a: a8 Q3 v .name = "user_led3",: w! @5 X2 o5 o8 N% z
.default_trigger = "default-on",
6 u4 d0 s! {+ [# M' z },
" ?/ Z. v/ I/ |};, Y4 q+ e8 j5 u. G
! C4 `$ @4 r1 J$ s. S- D0 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( k6 W7 w3 i" k% z- [9 v .leds = da850_evm_tl_leds,
+ ^3 A2 o3 n9 r5 P1 r .num_leds = ARRAY_SIZE(da850_evm_tl_leds), a6 T+ U% o. {; W( e) c
};
7 H# D* L- r6 j, c) z. k0 h. i: L2 p6 _2 q+ {$ A& L( @* p
static void led_dev_release(struct device *dev)% r3 l) [5 _( W& e
{
' r% ^" i: X' `};! a# }/ v! N# T6 n4 ?& [
3 ]( s3 y( F+ }* mstatic struct platform_device da850_evm_tl_leds_device = {
. J, n, `3 D: L& l2 ~ .name = "leds-gpio",
3 e' T2 n' Q" c# v6 w2 h9 }+ G R .id = 1,
: h% `$ s8 T" x% Y; y* o; U .dev = {7 n( T- x, F7 _1 x) r
.platform_data = &da850_evm_tl_leds_pdata,
9 l0 h, b9 z/ S: C' R6 p8 f1 y .release = led_dev_release,
E; V( ~) S8 `$ l7 }$ d }
+ W( p/ o8 t& N* ^7 H};
' W, I: y' S- j& ^$ D$ _4 ?2 P. K
@8 Y" X* K/ J9 Hstatic int __init led_platform_init(void)
$ r9 E4 A' c1 G; h{6 f6 u1 g1 c) P2 J
int ret;0 I8 ]# U5 g/ W# v* S
#if 0
. S! [* {7 h/ v/ A ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% Q" A& d) j+ v% F if (ret)
6 Z' N" h7 o! J pr_warning("da850_evm_tl_leds_init : User LED mux failed :": X9 k+ G" L, h; H
"%d\n", ret);: A: I2 D& s" j6 j h* [$ ^4 p" |
#endif
! ~' S6 r4 \2 H& S8 V/ f ret = platform_device_register(&da850_evm_tl_leds_device);' m' M+ ~/ }7 O! E- P# D
if (ret)
+ D+ t$ \- m2 a7 y! m pr_warning("Could not register som GPIO expander LEDS");
9 u3 I! }" D7 Z u/ W else
, b7 |* e+ Z# I2 W8 O printk(KERN_INFO "LED register sucessful!\n");! m5 d6 V5 r+ }) G5 t
+ y6 W0 a, S8 \) W! a1 l# H) \9 l8 U
return ret;
# s: |5 y4 v3 e" l! ^/ q}# s5 P7 _9 |4 @
* N: G0 [; x4 ^8 n3 Y/ e
static void __exit led_platform_exit(void)
& }* D! ^2 z! v0 A# c; h" e, ?8 p7 V{
9 l: m {0 Q7 J platform_device_unregister(&da850_evm_tl_leds_device);6 ~" N& U6 z- u# K2 U
* Y8 F& D4 Q2 `' l6 w* S printk(KERN_INFO "LED unregister!\n");2 s3 B( S" g3 Z+ A: U9 q" z! e z
}
& ` i- |+ c8 i) n2 p) G
: _4 F& l) S, C# omodule_init(led_platform_init);3 [& g6 A5 E5 |( J9 I
module_exit(led_platform_exit);
- \) ^" _. B2 a: [. s' p- J: A( u: ], U/ Z
MODULE_DESCRIPTION("Led platform driver");
( j6 M5 G b! ?: z! G* t. n5 i' _7 ]MODULE_AUTHOR("Tronlong");
" V+ h8 z, s% v1 QMODULE_LICENSE("GPL");
q2 C5 P- }2 s. a7 f2 Z6 t j2 ?. s2 W8 A6 A3 B! C; N' X, q* W
|
|