|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- h4 l3 g& p; }7 ]9 q: D+ q#include <linux/init.h>
3 ^! z( M6 G+ t) L# }/ U#include <linux/module.h>& v5 [1 u' }0 S; e `
#include <linux/kernel.h>9 `' T0 u" I' |# |9 W" _
#include <linux/types.h>
! _5 @, y0 B. S: v4 S#include <linux/gpio.h>
8 H( K" u5 Y5 y7 _# t% p#include <linux/leds.h>
" ]9 @0 E; k( \# d#include <linux/platform_device.h>
5 W9 W& H+ E; a* f
) k. P6 c+ Y# E# s9 q \* O#include <asm/mach-types.h>
( u( E4 H% C# Y/ f. K1 a8 q#include <asm/mach/arch.h>
9 M/ F5 t9 v) F! I' l, d#include <mach/da8xx.h>
3 C/ m* o* i. k0 Q#include <mach/mux.h>
3 o( U# G* M- S9 _# L/ o' }
. h: v% x, L& e. B#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) _% d: \3 U2 d& C! @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 i c% Q4 ^. U3 F0 N+ U( T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( Z( e) V9 C1 V g2 Q5 a! u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, S2 j/ S* \; R$ \8 _' X3 F+ Z' p2 {# p+ N6 Z x' I* K
/* assign the tl som board LED-GPIOs*/
4 y% G' R5 ^" o: d- \0 F) }- cstatic const short da850_evm_tl_user_led_pins[] = {) T F( |% X+ q, p5 q% s
/* These pins are definition at <mach/mux.h> file */
$ p1 a6 A/ n9 b' C4 N8 h DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
q9 E0 G$ ]1 n -1
j2 c1 X) z9 m/ ?};+ O& U1 }3 j$ j
6 z9 T2 Y2 J& }7 K0 R b; Nstatic struct gpio_led da850_evm_tl_leds[] = {$ G4 s8 D9 F! j! W4 |6 M# A: t
{
. d5 s) k- V* o* u$ `* H .active_low = 0,
) D3 T; o* o& r) d5 s. G, h .gpio = DA850_USER_LED0,
R# L& F6 R) r3 z .name = "user_led0",, U. \; n: R4 f+ p( K, x' {
.default_trigger = "default-on",
' `0 l) R' q" @' b3 r* K; g },
f3 Z& D. ?2 r; u+ S7 C {. S3 A6 [# Z! s r
.active_low = 0,
( W1 L7 x8 D. l. E6 g/ i @ .gpio = DA850_USER_LED1,
0 N! W. W: ]& U .name = "user_led1",: M" Q6 `, }+ ~( P3 f
.default_trigger = "default-on",# {) `! C8 J) |5 u. E
},
, A' w& o$ b( M" j- P% A, q {9 x5 t4 G5 {9 L( H1 o1 B
.active_low = 0,
5 k% a2 s* y. |1 v A+ F9 e. V3 u( H% ~ .gpio = DA850_USER_LED2,! g+ W& M5 w# v7 U/ E- K4 U
.name = "user_led2",
- t. z0 ]% t' V I# Z& H9 T2 s .default_trigger = "default-on",& c1 G( W4 l, r1 X) W- p4 o
},
3 f0 i9 c. N5 G4 I4 G! d {( w2 ^ G! E: r, a
.active_low = 0,1 b# F4 F1 e9 l( y4 g6 x0 ]
.gpio = DA850_USER_LED3," a$ n( o0 g% X- k4 I
.name = "user_led3",$ D6 u& f+ q6 y9 F5 q
.default_trigger = "default-on",
4 Y1 O9 J# V7 O0 S9 S },
" B( Z7 |" v0 e};. c- X6 U0 ?$ `+ b* f2 w7 Q
7 G* q8 [! O# C1 g: h1 _' S& c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 e4 K8 u0 q! F e* ~8 P .leds = da850_evm_tl_leds,! o2 v# z1 Z. F+ j4 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* c9 R1 z! Y9 P- r! `0 t5 Z& g) Y
};3 m9 T4 I( x9 r' n
6 F& E7 T8 ~7 b+ p o2 F4 X) Zstatic void led_dev_release(struct device *dev)
$ F7 I5 Y: _, K. H{
3 B' Z' Z; B% B. p& B; \};
) {% L, s9 o2 A9 D+ {
* W# t2 @9 |- @+ Z* ustatic struct platform_device da850_evm_tl_leds_device = {
& U- p9 f7 R% P% e5 ` .name = "leds-gpio",
% W1 v r) n7 r+ C .id = 1," a9 o. C4 C' n6 D, Q: x& t
.dev = {: ]' z5 R5 T1 d# H& k
.platform_data = &da850_evm_tl_leds_pdata,
: u1 ]( Y; d+ l1 D4 c$ l) s: x, J .release = led_dev_release,- G, Q8 s' b4 c- k
}0 l; N& q& B: A8 i* H
};7 w% T" U5 C- q2 Q7 P5 f9 a5 T; c, E
9 K2 o! s4 q z! t$ ? istatic int __init led_platform_init(void)% ^2 {4 D* z! e7 C& }/ F; _# a
{
! b+ `; D+ J2 i int ret;
& B2 L' N+ f# o/ p, K#if 02 `% j- q9 v4 y' T) V0 R$ T+ R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 b6 I& M0 N1 M; b1 a
if (ret)7 X1 w' Z: H2 a5 C1 d2 }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", J( c8 w/ M& f" a% }. q
"%d\n", ret);6 m2 m5 m+ Q) V( B) r! `5 E) G
#endif
" @) k$ t5 A3 \: n ret = platform_device_register(&da850_evm_tl_leds_device);, @ s# W3 T6 N2 i
if (ret)
; Q% b. y+ b n* Q4 v pr_warning("Could not register som GPIO expander LEDS");
8 z" P1 Z9 @4 O1 Y' f+ N else
3 p9 S) r3 `8 R printk(KERN_INFO "LED register sucessful!\n");8 f( e R; X. s: n( Z0 ~
+ N& y. p: E+ U- j3 z$ m return ret;- p/ t; w: y# z! ~& X$ v8 x/ I
}
. b0 u V. \' c9 h) u
: u( |' L% S4 @static void __exit led_platform_exit(void)
* g, F$ P% W Y, D{ `0 X' B0 b* q
platform_device_unregister(&da850_evm_tl_leds_device);
0 E8 g& y8 T$ a. b# G" j( s; L% C$ x3 K. e
printk(KERN_INFO "LED unregister!\n");8 V, H# o. F: H$ Z9 O
}. d3 A% ], ?9 ~; c e" P
b. h+ Y7 H2 p1 p" j- ^0 L
module_init(led_platform_init);
- z5 [# w/ K0 v) M$ Fmodule_exit(led_platform_exit); c/ ~& d$ }2 }0 D
3 p; s0 Y. O- W0 x4 |" c. X, iMODULE_DESCRIPTION("Led platform driver");" q2 g6 q! C! q' Z
MODULE_AUTHOR("Tronlong");
8 F4 ?0 B# R, L) { p& T( p' w4 iMODULE_LICENSE("GPL");
# c# S3 r1 H6 s6 v( _+ j+ Q0 w; k0 z9 O$ P3 s
|
|