|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 o$ w- I7 ]% J% W: d% w i#include <linux/init.h>; R3 c* Z5 k l( q% f/ M
#include <linux/module.h>$ ~/ s) D9 d' S$ J( q& Y0 d( U
#include <linux/kernel.h>
, s: M: w% L- N* k+ @& K#include <linux/types.h>/ r* `: P+ f8 F% R
#include <linux/gpio.h>8 h0 c3 c$ U- r( i
#include <linux/leds.h>
) N6 }. _% C" d8 `9 m$ v#include <linux/platform_device.h>+ K5 N3 F8 B- e4 i H5 J5 M
$ A( z7 `1 r# E: Y' q2 ^) v
#include <asm/mach-types.h>" w: f6 h. V$ X) w( O
#include <asm/mach/arch.h>
2 p4 P. m W$ l5 H2 e: J#include <mach/da8xx.h>) \1 N2 d: P& f: z7 a: O& B1 F
#include <mach/mux.h>
8 @( O7 i/ O: S6 R& G3 F8 W) D8 v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) T0 q0 @2 p4 X9 U* L1 ^, ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! A3 i& T4 k Z1 _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) W1 T# h% B) C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# x! Y& j* \3 b1 N' j
6 F3 c. u5 b3 O8 W, U
/* assign the tl som board LED-GPIOs*/
: A3 H- C% r! \9 N; {4 ostatic const short da850_evm_tl_user_led_pins[] = {
4 h- M2 y/ q% ^ /* These pins are definition at <mach/mux.h> file */
1 R v. ~" l _; k8 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ v9 W6 ~" I, u
-1
" p) y- C" G0 L. _};
( Z' a% X! t9 A( ?2 r* |7 t8 c% `* c$ |" N
static struct gpio_led da850_evm_tl_leds[] = {& X( O0 p, p) q: m6 T0 k
{
' L c9 t9 J* y5 _3 ~ Z& p0 X .active_low = 0,9 f0 S" h5 X+ o* H
.gpio = DA850_USER_LED0,
5 @, C# x7 z' D8 b3 C3 T: S. ^/ t .name = "user_led0",4 F/ k- k) } X7 c% t! M( J, W
.default_trigger = "default-on",
& q$ Z7 c; z' v0 W },, s [, u, L6 Q1 W/ {
{
$ U* w, X0 h( R. V3 d .active_low = 0,1 t- e _$ m( t" p. y0 |" |9 A0 w
.gpio = DA850_USER_LED1,8 a) Y! l, `2 J- m+ U
.name = "user_led1",1 B8 Z1 ^; x+ i; w% [" ?# t9 U0 a
.default_trigger = "default-on",
- G& H' R: l' j, S. ~ },
# d6 {' i% i6 ~! z {
0 W- E# `, u3 y .active_low = 0,
' S' Z4 T# z1 |+ B" h p1 x .gpio = DA850_USER_LED2,, `9 F( w6 a; Q7 h+ Y
.name = "user_led2",
3 W3 k1 G1 F9 T7 R .default_trigger = "default-on",( B. a- s i& }1 T c. }
},
9 {3 h" M3 K% Q6 x% V2 j9 z {7 a7 d* @! X+ X1 S, h
.active_low = 0," [2 ~/ ^' [+ r& N% S
.gpio = DA850_USER_LED3,
: L' [0 {) A% w; o7 A# _$ @ .name = "user_led3",+ ~% {; z. ?* c8 Y
.default_trigger = "default-on",
" E; x8 l/ x' A) D5 m5 v },
- U3 A7 u* O& }9 b$ W* l7 D};
: X$ M5 `# {7 c- H6 s0 w
/ ?* j% S) S' w9 vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 T- J# R/ y/ v9 a& T. ~ .leds = da850_evm_tl_leds,
$ ~3 ^: a' m* n% \! y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' y$ Y E( J; p. U/ o};- P+ u% Y7 Z! G. C" @7 x
" e9 e+ Z$ s, _9 R1 ^. o
static void led_dev_release(struct device *dev)
1 Q$ T$ W7 D2 x4 }4 m{
: ?" |! z0 l9 B) U1 v};
7 B0 {# d C$ |& e, v0 N0 H! v) |* i' J; g, k
static struct platform_device da850_evm_tl_leds_device = {
~- E/ p- @. ?! A .name = "leds-gpio",# H! c. H. z( N j
.id = 1,
* j, N. L" B1 V" N .dev = {
# ]0 Y( ?$ l4 D1 D* i5 \3 W4 {' d6 P .platform_data = &da850_evm_tl_leds_pdata,
2 ~4 P; g0 m. X: f6 e/ c .release = led_dev_release,
& }6 [% `+ p- S4 j! X* ? }: U" V$ K" X! X! ^
};
2 S8 B& W4 _, m. ?% C( T9 J
- n. \& ` c( Y, e% \! Hstatic int __init led_platform_init(void)
7 A3 o O* Y# E0 `" M{8 o6 c2 w8 r; F! d
int ret;
; b- U9 \" Y ]# U0 n#if 0
& V/ _: L' u2 W3 R# X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 ^' ~! A6 _/ m- F) L, S if (ret). V: V2 H0 n, @# T4 X) I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 H, o @% a0 K+ [
"%d\n", ret);
% R* u- A8 t s* e+ s+ D#endif9 O. J& l, P" E. ` ~/ @
ret = platform_device_register(&da850_evm_tl_leds_device);
; d. Q' n) H( g" p: G if (ret); ?& ?$ U$ B' J: V* f1 f
pr_warning("Could not register som GPIO expander LEDS");3 V* p: s; B) T3 f
else
! @( i* q# Y2 h printk(KERN_INFO "LED register sucessful!\n");7 G1 }% E- u4 n6 w6 B4 {
9 S" ?- q6 G( }/ t" ~; p+ x( g7 d- ^
return ret;$ C) I. s. D' _+ a r
}! u. z0 T2 O- r) D; S" s
9 C" E5 F3 x4 w, C/ g: g" f+ Q
static void __exit led_platform_exit(void)3 r& `* U# T0 P! ^7 ]
{
2 }, _4 s, w q' Y7 v platform_device_unregister(&da850_evm_tl_leds_device);
1 O7 N5 Y7 G3 O4 V: g. K% C$ R3 Q' v4 h: \
printk(KERN_INFO "LED unregister!\n");
4 J* ]$ K* [. H7 m# s; F}, m( E! V1 j' q* O7 I
' P' }" c% I8 U1 c3 C k \0 emodule_init(led_platform_init);
1 x- j2 |0 k) Bmodule_exit(led_platform_exit);$ s5 q |4 a' ?" }4 y/ X1 p$ q
) P% a! k3 o2 s5 x0 ^" {: ]
MODULE_DESCRIPTION("Led platform driver");" t4 R' i" c# L7 F
MODULE_AUTHOR("Tronlong");
/ l0 A/ t( ^5 uMODULE_LICENSE("GPL");
* D) S% U8 G e7 R- n C# h# {2 Q; L. ^
5 z0 B X8 w% c. _ |
|